Hi!
I want to build the following SQL with LLBLGen
SELECT addressID, COUNT(*) as c
FROM [order]
GROUP BY addressID
ORDER BY c desc
The only problem is the ORDER BY expression. I don't know how to do that. This is my code:
ResultsetFields fields = new ResultsetFields(2);
fields.DefineField(OrderFields.AddressId, 0, "SumOfAmount");
fields[0].AggregateFunctionToApply = AggregateFunction.Count;
fields.DefineField(OrderFields.AddressId, 1);
GroupByCollection groupBy = new GroupByCollection();
groupBy.Add(EntityFieldFactory.Create(OrderFieldIndex.AddressId));
ISortExpression sortExpression = new SortExpression();
sortExpression.Add(new SortClause(fields[0], SortOperator.Descending)); // not compilable!!!
DataTable results = new DataTable();
mAdapter.FetchTypedList(fields, results, filter, 10, sortExpression, true, groupBy);
The code line new SortClause(fields[0], SortOperator.Descending) is not compilable! Error message is:
Argument type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2' is not assignable to parameter type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField'
I found examples on the internet with exactly the same code. So I guess something has changed in LLBLGen 2. What's the correct code?
Thanks in advance for your support.