Query service
The query service enables us to retrieve data from Microsoft Dynamics AX without having to use the .NET Business Connector or, even worse, access the SQL database directly.
By using the query service, you can fetch data using any of the following query types:
Static query: This is used to retrieve data by using queries that are present in the AOT. We will use this type in the demonstration.
User-defined query: A query can also be created by using the
QueryMetadata
class. By doing this, you can create a query in the same way as you create queries in X++ code.Dynamic query: Another way of running a query is by creating an X++ class that extends the
AifQueryBuilder
class. You can invoke theExecuteQuery
operation by passing in the name of the query builder class. It is also possible to pass arguments by using a class that extends from theAifQueryBuilderArgs
class.
Fetching data for the grid
Now let's put some code behind the clicked event handler of the Refresh button. The idea is...