Book Image

Microsoft Dynamics AX 2012 R2 Services

Book Image

Microsoft Dynamics AX 2012 R2 Services

Overview of this book

Table of Contents (17 chapters)
Microsoft Dynamics AX 2012 R2 Services
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

The 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 using queries that are present in the AOT. We will use this query in the demonstration.

  • User-defined query: A query can also be created using the QueryMetadata class. By doing this, you can create a query in the same way 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 the ExecuteQuery operation by passing in the name of the query builder class. It is also possible to pass arguments using a class that extends from the AifQueryBuilderArgs class.

Fetching data for the grid

Now let's put some code behind the clicked event handler of the Refresh button. The idea is to invoke...