You can excess AOT query directly in your dot .net code. For this purpose I predefine AIF services comes with dynamics ax 2012. These services return data in dataset and paging mechanism you can handle large sum of data set. I my last example I create a student table with following fields.
FieldName | dataType |
Roll Number | string |
FistName | string |
LastName | string |
Address | string |
DateOfBirth | date. |
. To test the query services first we create a custom AOT services on Student table. For example I create a very simple query as following screen.
You can access query service with following url
http://[HostName]/DynamicsAx/Services/QueryService
After that I create a console application in visual studio to get dataset by calling Dynamics AOT static query in dot net code with the help of AIF Query services.
You can add services reference as
I am creating Query reference with Namespace of QueryServiceTest.
Now in console application’s main method we call Query service and provide it AotQueryName and pageing object as follow. I am trying to fetch all the records form my custom Student table.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
namespace TestAIFQueryServices
{
class Program
{
static void Main(string[] args)
{
QueryServiceTest.QueryServiceClient _QueryClient = new QueryServiceTest.QueryServiceClient();
DataSet dataSet;
QueryServiceTest.Paging paging = null;
dataSet = _QueryClient.ExecuteStaticQuery("StudentQuery", ref paging);
foreach (DataRow dr in dataSet.Tables[0].Rows)
{
Console.WriteLine(dr["FirstName"].ToString() + " " + dr["FirstName"].ToString());
}
Console.ReadKey();
}
}
}