I know Aurelius can do paging by using Take and Skip, but I can't find in the manual any way to return the whole count which we need for the UI. The manual says that using Take(0) will return an empty result so my question is: how do I make sure to have all the meta-information (total count, etc.) to send to the client?
var
ResultData: TVisiteDynResult;
ORM: TObjectList<TSSTPERSONALE_VISITE>;
ORMVisita: TSSTPERSONALE_VISITE;
CountResult: TCriteria;
Then in the code:
if start = 0 then
begin
CountResult := ObjectManager.Find<TSSTPERSONALE_VISITE>.Select(TProjections.Sql<Int64>('Count(*)')).Clone;
CountResult.AutoDestroy := False;
ResultData.total_count := CountResult.UniqueValue.Values[0];
end;
And then releasing it in my finally. Unfortunately, I am still having memory leaks, so I am certain something isn't quite right. The remainder works as intended so the problem is here, in how I get and use the count.
The Clone is just needed if you are using the original criteria for the query itself. If you don't, then you don't need neither Clone or AutoDestroy. Just do this:
Yes, I want both the count and the list, for I am doing paging and I may need both
Your suggestion obviously worked for intended purpose. but alas I need to be able to do both the count and the list with the same criteria
Well, you should copy, paste and adapt to your needs. I can't tell you where to put it, because I don't know what you want to do with it? What is your need, exactly?