Edge and relationship expansion queries - SmartPlant Foundation - IM Update 44 - Customization & Programming - Hexagon

SmartPlant Foundation Customization

Language
English
Product
SmartPlant Foundation
Search by Category
Customization & Programming
SmartPlant Foundation / SDx Version
10

The DAL query engine supports searching for related objects from any number of source objects through any number of relationship and/or edge definitions.

This is supported on the EdgeExpansionDynamicQuery class, which returns a set of partial objects and allows you to run an edge or relationship expansion based on a set of source objects. However, you must define the set of columns that you are interested in.

Dim lobjEdgeDynamicQuery As New EdgeExpansionDynamicQuery(lcolSourceObjects)

lobjEdgeDynamicQuery.Query.Add("+Implies", lcolColsOfInterest)

Dim IPartialExpansionResult lcolExpansionResults = lobjEdgeDynamicQuery.ExecuteToPartialExpansionResult()

This query returns a set of partial results made up of the columns that you requested. The results of the expansion can be paginated by each relationship and edge definition and ordered by the target object properties to meet any requirements.

  • Target objects cannot be ordered by related item properties.

  • Edge definitions work in the same way and can be paginated for any number of starting and target objects.

Example

The following image shows a query for the first five documents and tags that are related to a folder using the relationships FolderDoc and FolderTag respectively.

If multiple folders were supplied as the starting objects, the results would be split by folder and then by relationship. So expanding from two folders returns ten tags and ten folders in total, as shown in the following image:

The paging can be defined per expansion for a single query, so you could have queried for the first ten documents and the first five tags.

Dim lobjEdgeDynamicQuery As New EdgeAndRelExpansionDynamicQuery(pcolSourceFolderObjects)

Dim lobjFolderToDocumentExpansionInfo = lobjEdgeDynamicQuery.Query.Add("+FolderDoc", lcolResultColumns.ToArray())

lobjFolderToDocumentExpansionInfo.Skip = 0

lobjFolderToDocumentExpansionInfo.Top = 5

lobjFolderToDocumentExpansionInfo.OrderByCriteria.Add(New OrderByCriteria("Name"))

Dim lobjFolderToTagExpansionInfo = lobjEdgeDynamicQuery.Query.Add("+FolderTag", lcolResultColumns.ToArray())

lobjFolderToTagExpansionInfo.Skip = 0

lobjFolderToTagExpansionInfo.Top = 5

lobjFolderToTagExpansionInfo.OrderByCriteria.Add(New OrderByCriteria("Name"))

Dim lcolExpansionResults As IPartialExpansionResult = lobjEdgeDynamicQuery.ExecuteToPartialExpansionResult()