Dynamics Ax custom WCF service with paging support

Hi all,

Lately I’ve been busy developing WCF services to communicate with .NET web applications. All of these web services are custom-made and are using .NET data contracts so that every application uses the same contracts. Due to the high amount of data and performance we had to implement some kind of paging. I had no clue that Ax even has paging support but it does and it does this with properties on the QueryRun objects.

For example purposes I’ve made a service which uses .NET request and response contracts. I prefer this way over X++ data contracts because this is more reusable and flexible on the client side. The code is self-explanatory to me but you can always pose questions of course. 😉

The request contract:

The response contract:

The service implementation:

Calling the service from a .NET application:

Paging on a QueryRun is implement since Ax 2009, more info on paging: http://msdn.microsoft.com/nl-be/library/aa623755(v=ax.50).aspx

I wonder why this isn’t implemented in the AIF services or is it? If anyone knows please leave a comment about it. 😉

4 thoughts on “Dynamics Ax custom WCF service with paging support”

  1. Interesting article :). I had to make modifications to standard AIF so that a sorting field could be passed in, so that i can handle the 1000 row limit. I could use this in that and make it better 🙂

    1. Hi Shashi,

      That would be a way better option, I’ve dived into this with SQL tracing and I’ve noticed that the paging is handled on the SQL server witch I hoped for. 😉 So on large tables this would be a very good performance win. 🙂

      Kind regards,

      Kevin

      1. Managed to do a test with this in x++, seems that the paging works across all records in a query. i.e. if the paging records is set to 100, and the query involves a join of 2 tables, then 100 includes the records retrieved from both the tables. Do you know how this is handled within SQL server? Makes it hard if you want to be paging the top most record (unless pagingByValue is used?)

        1. Hi Shashi,

          Sorry for the late reply, I’ve been busy lately.
          That is correct only 100 results will be returned regardless of the tables that are joined. I have no experience with value based paging as this works for us as desired.

          Kind regards,

          Kevin

Leave a Reply