tvuong wrote:
Otis wrote:
This creates a dynamic list, so a list based on a typed view, which is what you needed
, it creates a query using the meta data of the typed view, and the results are stored in a normal datatable. Please see the typedlist/view documentation, for a discussion on dynamic lists. You'll use the TypedListDAO object to retrieve the data, which is ok, typed views are also fetched using that same code
OK, on the designer, I added entities for TypedView and be able to clear the errors.
Still, the fields that I defined still not being aggregated.
Thanks,
Ah, I think I understand what's the problem. (pfew
)
First I'd like to clear up something. Your code has lines like:
fields.DefineField(OrderDetailFieldIndex.CustomerId, 3, AggregateFunction.None); and the 3rd argument is always the name of the field, so I don't understand how that could have compiled.
Now, what you've to do is either:
- create a typedview in LLBLGen Pro designer for the view vw_a
OR
- create an entity mapped on view vw_a
Call that typedview or entity 'VwA'. (just for the sake of the example). You shouldn't confuse typed list with typed view.
Ok, then use this code:
// in your query you had 4 fields.
ResultsetFields fields = new ResultsetFields(4);
// SELECT COUNT(fID) AS OrderCnt, cNm, cID, SUM(cTot) AS TotalSpent
fields.DefineField(VwAFieldIndex.FID, 0, "OrderCnt", string.Empty, AggregateFunction.Count);
fields.DefineField(VwAFieldIndex.CNm, 0, "cNm");
fields.DefineField(VwAFieldIndex.CID, 3, "cId");
fields.DefineField(VwAFieldIndex.CTot, 1, "TotalSpent", string.Empty, AggregateFunction.Sum);
// Create group by collection, first cNm then cId
IGroupByCollection groupByClause = new GroupByCollection();
groupByClause.Add(fields["cNm"]);
groupByClause.Add(fields["cId"]);
// then create the between filter.
PredicateExpression filter = new PredicateExpression();
filter.Add(PredicateFactory.Between(VwAFieldIndex.ODt, DateTime(1, 5, 2005), DateTime(2, 5, 2005)));
// then use TypedListDAO.GetMultiAsDataTable() to fetch it in a datatable.