How to: Query UML Data in Modeling Services
[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]
This is the third topic in the Walkthrough: Using the Microsoft.Uml2 Domain. The preceding topic is How to: Browse the UML Data in "Quadrant"; the following topic is How to: Export UML Data as an .xmi File. This topic shows how to use Microsoft code name “Quadrant” to query the UML data loaded in How to: Load an .xmi File By Using "Quadrant".
Querying UML data in “Quadrant”
On the File menu, click New, and then click Workpad to create an empty workpad.
Type the following Microsoft code name “M” query syntax to show all the packages within the DinnerNowDesign folder, and then press Enter.
Microsoft.Uml2.Packages where value.Folder == (Repository.Item.FoldersTable where value.Name == "DinnerNowDesign" select value.Id).Choose
Switch the workpad’s viewer to UML Packages Browser.
Expand the Dinner Now Class Model – Lucerne Integrated Payment System to find details about its child elements.
Change the workpad’s viewer to List view.
Modify the previous query to show only those packages that contain the name
Data
within the DinnerNowDesign folder.Microsoft.Uml2.Packages where value.Name == "Data" && value.Folder == (Repository.Item.FoldersTable where value.Name == "DinnerNowDesign" select value.Id).Choose
Reuse the workpad query bar to test various queries.
Note
Make sure you set the viewer for the workpad to List before executing these queries.
Select all packages that are root packages.
Microsoft.Uml2.Packages where value.OwningPackage == null
Show all packages that have a class in them. For more information, see Classes Function (Microsoft.Uml2 Module).
from p in Microsoft.Uml2.Packages from c in Microsoft.Uml2.Classes where p.Id == c.OwningPackage && c.ElementKind == "Class" select {PackageName=>p.Name, ClassName=>c.Name}
Find the total number of components in the Modeling Services database. For more information, see Components Function - Microsoft.Uml2 Module.
Microsoft.Uml2.Components.Count()