Auxílio com consultas onde é necessário group by com sum em campos

I would like to make a query which returns a list of objects. exe:
list of products with stock balance, but the repeated products need to be grouped by adding their stock balance.
How can I do this query? should i use projections?
I couldn't find any example for this.


product balance
test1 2
test2 1
teste1 3

result queries:

test1 5
teste2 1

Hi Aléssio,

Yes, you should use projections, and it's described in the documentation:

Results := Manager.Find<TEstimate>
  .CreateAlias('Customer', 'c')


yes, but how do I get the object list from TCriteriaResult?

uses {...}, Aurelius.Criteria.Projections, 
  Aurelius.CriteriaBase, Aurelius.Criteria.Linq;

  Results: TObjectList<TCriteriaResult>;
  Results := Manager.Find<TTC_Estimate>
    .CreateAlias('Customer', 'c')

  EstimateSum := Results[0].Values['EstimateSum'];
  CustomerName := Results[0].Values[1]; // no alias specified for c.Name

Results[0].Values[1]? i try but not sucess

Correct, that's how you get the individual scalar values from each projection. There is no object list. Just a list of TCriteriaResult objects, and each TCriteriaResult has a list of scalar values.