Hi I'm searching for the start index for my aggregate to do some pagination but I can't find it in the Properties ? Here is the Photo :
Hi @Mohamed Ali LAJNEF ,
the StartIndex property on aggregates only exists when it is a screen aggregate, not when it is an aggregate inside a server action (which a DataAction kind of is).
If you want to apply pagination with aggregates inside server actions, you'll have to write your own logic for it.
This article by @Kilian Hekhuis is a good read.
The article works on the premise of retrieving the full list in one go from the DataAction, I'm not always a fan of that when there is a lot of data to get.
Alternatively,
With this approach, performance will only deteriorate as you go further to the later pages in your pagination, which I think your user should never have to do anyway.
Dorine
Hello Mohamed Ali LAJNEF, It seems that you didn't understand some basic stuff. No worries :) Check the following documentation steps and the following two videos :) It has examples of how to do it! If you follow the steps you will not have problems:
Best regards,
Ana
An alternative solution would be to convert the aggregate to an advanced SQL, passing in StartIndex and MaxRecords as parameters, then append the following at the bottom to the SQL query:
OFFSET @StartIndex ROWS
FETCH NEXT @MaxRecords ROWS ONLY
This syntax is explained in detail in this tutorial.
This "high-code" approach may not be appropriate for everyone, but it avoids the potential performance impact of loading all data at once (as in Kilian Hekhuis's article).
Recently I had to implement a complex query and this was the best approach. Important to say that the ORDER BY clause is required in this case, as shown in the linked tutorial.