Grouping a EntityCollection

Posts   
 
    
Intersolve
User
Posts: 5
Joined: 14-Jul-2005
# Posted on: 21-Apr-2006 13:19:09   

I want to group an EntityCollection and do a AggregateFunction.Sum on a particular field. Is this possible or must I use a TypedViewList?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 21-Apr-2006 16:23:58   

Either you loop inside the colection and calculate the sum yourself, or use a TypedList, TypedView or a dynamic List instead of the EntityCollection.

Intersolve
User
Posts: 5
Joined: 14-Jul-2005
# Posted on: 21-Apr-2006 20:28:09   

Walaa wrote:

Either you loop inside the colection and calculate the sum yourself

confused confused confused Looping through a collection with a size off a 1000 entities isn't very efficient. Is it? SQL is must better in aggregating decimals. So I'll use a typed list.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 21-Apr-2006 20:39:06   

Walaa was referring to the fact that you can't fetch an entity collection with an aggregate. So you have to use different ways to get the aggregated value if you already have the collection / want to use the collection, e.g. manually traverse the list. A typed list is one way to get the value, you can also look into a scalar query or a dynamic list.

Frans Bouma | Lead developer LLBLGen Pro