Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Michael on May 13, 2013, 10:05:21 pm
-
How can I get a node by GUID
I have a guid string
and I want to get the related Node
Thanx
-
A deployment Node is a type of element, so you can use Repository.GetElementByGuid(<...>)
-
Or you could use an sql search:
select instance.ea_guid as CLASSGUID,instance.Object_Type as CLASSTYPE,instance.name as Name, package.name as PackageName ,package_p1.name as PackageLevel1,package_p2.name as PackageLevel2,package_p3.name as PackageLevel3
from ((((t_object instance
inner join t_package package on instance.package_id = package.package_id)
left join t_package package_p1 on package_p1.package_id = package.parent_id)
left join t_package package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package package_p3 on package_p3.package_id = package_p2.parent_id)
where instance.ea_guid like '#WC#<Search Term>#WC#'
Geert
-
Just curious
What is the difference / advantage of the SQL query posted by Geert and this SQL query
select instance.ea_guid as CLASSGUID, instance.Object_Type as CLASSTYPE, instance.Name as Name
from T_Object instance
where instance.ea_guid like '#WC#<Search_Term>#WC#'
Instead of using like another query could be simply
where instance.ea_guid = '#WC#<Search_Term>#WC#'
Cheers
Phil
-
Thanks
OK
good solution
-
Just curious
What is the difference / advantage of the SQL query posted by Geert and this SQL query
select instance.ea_guid as CLASSGUID, instance.Object_Type as CLASSTYPE, instance.Name as Name
from T_Object instance
where instance.ea_guid like '#WC#<Search_Term>#WC#'
Instead of using like another query could be simply
where instance.ea_guid = '#WC#<Search_Term>#WC#'
Cheers
Phil
Hi Phil,
If you change the "like" to a "=" then you should also remove the "#WC#" wildcards.
I thought about that, and for a guid that makes sense of course, but you never know someone might forget the curly braces, or by accident only copy part of the guid...
I don't think it will hurt much performance wise.
The advantage of joining all of those parent packages is that you get an idea of the context of the element returned by the search. I can see in an instant which element is the one I need, without having to select it in the project browser.
I've added those to all of my searches; its sort of a habit.
Geert
-
Thanks Geert, thanks makes sense