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