Microsoft Dynamics AX 2012 R3 Development-3 Locus IT Services

Microsoft Dynamics AX 2012 R3 Development-3

Locus IT ServicesMicrosoft Dynamics AX 2012 R3 Development-3

Lesson 2 : Query

Query using X++

A query is an object-oriented interface to the SQL database. A query is composed of objects from different classes.Various objects are available to manipulate a query object from the AOT. Query using X++

Use the queryRun object to execute the query and fetch data.The query object is the definition master. It has its own properties and has one or more related data sources.

The queryBuildDataSource defines access to a single table in the query. If one data source is added below another data source, they form a join between the two tables.

The queryBuildFieldList object defines which fields to fetch from the database. The default is a dynamic field list that is equal to a “select * from …”. Each data source has only one queryBuildFieldList object which contains information about all selected fields. You can also specify aggregate functions like sum, count, and avg with the field list object.

The queryBuildRange object contains a limitation of the query on a single field.

The queryFilter object is used to filter the result set of an outer join. It filters the data at a later stage than the queryBuildRange object and filters the parent table based on the child table results.

The queryBuildDynaLink objects can only exist on the outer data source of a query. The objects contain information about a relation to an external record. When the query is run, this information is converted to additional entries in the “where” section of the SQL statement. The function is used by forms when two data sources are synchronized. The subordinate data source contains DynaLink(s) to the master data source. The function is used even if the two data sources are placed in two different forms, but are synchronized.

The queryBuildLink objects can only exist on inner data sources. The objects specify the relation between the two tables in the join.

Locus IT Project Management Office
What’s it?