Is it possible to perform groupping operation on an entitycollection and project the result on a datatable?

Posts   
 
    
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 21-Nov-2008 16:43:47   

Inside a data-validation procedure I need to check some constraint. I have an entitycollection, and I need to count how many instance of a particular value I have in a column of this entitycollection.

Is it possible to use an already fetched entitycollection to perform gropupping / counting operation and project the result on a datatable?

From my understanding it's possible to do groupping operation when fetching data from the DB, but what about in-memory operation?

Sample data: My entityCollection

IDCustomer, IDDocument, Description, other data... 1 , 100 , 'blah blah blah...' 1 , 101 , 'blah blah blah...' 1 , 102 , 'blah blah blah...' 2 , 100 , 'blah blah blah...' 2 , 104 , 'blah blah blah...' 2 , 107 , 'blah blah blah...' 2 , 107 , 'blah blah blah...'

I would like to Group by IDCustomer AND IDDcoument, and count the instance of IDDocument, getting a result like

IDCustomer, IDDcoument, CountOfIDDocument 1 , 100 , 1 1 , 101 , 1 1 , 102 , 1 2 , 100 , 1 2 , 104 , 1 2 , 107 , 2

Naturally, in this case, I can loop trough the data and look for duplicate using a hashtable or something like that, but this is just the simplest case. There are other situation in which I need to calculate groupping/summing/various operation on in-memory entityCollection, ad it's not so simple as looking for duplicate value.

Thanks, Max

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Nov-2008 19:38:58   

Hi Max,

Unfortunately, Aggregates aren't supported in in-memory projections (ref...). Any change you can use .Net3.5 so you can take advantage of LinqToObjects?

David Elizondo | LLBLGen Support Team
Max avatar
Max
User
Posts: 221
Joined: 14-Jul-2006
# Posted on: 24-Nov-2008 10:25:55   

daelmo wrote:

Hi Max,

Unfortunately, Aggregates aren't supported in in-memory projections (ref...). Any change you can use .Net3.5 so you can take advantage of LinqToObjects?

For the moment we need to stick with .Net 2.0 because we have customer using Win 2K / Win98. Anyway, thanks for your support simple_smile