I'd like to compose a query to use with DgnECManager.FindInstances using an ECQuery. Unfortunately, the MstnPlatformNet documentation continues to ignore that class. The SDK examples help little, using the catch-all SelectAllProperties.
DgnECManager.FindInstances
ECQuery
SelectAllProperties
ECQuery query = new ECQuery(GetSearchClasses()); query.SelectClause.SelectAllProperties = true;
How can one write a query, say, to select Item instance properties having a certain value? That is, I'd like to know about ECQuery.SelectClause. If Item Types supported SQL, I would write something like...
ECQuery.SelectClause
SELECT * FROM MyItemType WHERE ID='abc'
Since DgnECManager.FindInstances returns IQueryable<> it's tempting to ignore the MstnPlatformNet API and use LINQ to compose a query. Which approach would you make your strategy?
IQueryable<>
Hi Jon,
I apologize for joining this thread late.
About .NET ECQuery documentation: I am trying to get whole bunch of .NET ECFramework documentation in U13 SDK. Robert Hook will let you know accordingly.
About using .NET ECQuery:
In ECQuery.SelectClause,
You call tell which properties you want: query.SelectClause.SelectedProperties.Add(..
You can tell what relationships you want w.r.t. searchClasses as:
QueryRelatedClassSpecifier relClassSpec = new QueryRelatedClassSpecifier (m_relationshipClass, false, ECI.RelatedInstanceDirection.Forward, m_targetClass, false); RelatedCriterion relatedPropertyCriterion = new RelatedCriterion (relClassSpec);
query.SelectClause.SelectedRelatedInstances.Add (new RelatedInstanceSelectCriteria (relClassSpec, true));
Please let me know if you are looking for something else.
Thanks,
Mangesh
Mangesh.Shelar said:I am trying to get whole bunch of .NET ECFramework documentation in U13 SDK
Excellent!
Mangesh.Shelar said:You can tell what relationships you want
At this point I'm looking at simple queries that concern a single Item Type and its properties. For example, suppose I want to query my AreaAnnotator Item Type, I want to write something similar to SQL statement...
SELECT ID, RoomType, occupied FROM 'Area Feature' WHERE occupied = True AND RoomType = 'Office'
That would evolve into a relationship when I want to get the area of the DGN element that is tagged with that Item Type...
SELECT ID, RoomType, occupied, Element.Area FROM 'Area Feature', Element WHERE occupied = True AND RoomType = 'Office' AND Element.Area > 500
FWIW I already wrote, with Paul Connelly's help, a C# demo that implements an EC relationship to harvest tag elements.
Regards, Jon Summers LA Solutions