I have a DataTable with over 100 columns and over 280 rows that I need to group by distinct UserID, and then process each row individually. The UserIDs are unique, however, there can be multiple rows for each UserID (each UserID can have from 1 to 20 rows associated with it). All the columns, including the UserID, are String values.
I have used code like this:
Dim src = From row In sampleTable.AsEnumerable()
to return an EnumerableRowCollection(Of DataRow), but when I try to group by the UserID column of the DataTable I get an error.
I need to group the rows in the DataTable by disinct UserID and process each row. I also need to keep track of every 10 distinct UserIDs I process in order to do subprocessing requirements.
How can I group a DataTable by distinct UserID and have access to all the rows that have duplicate UserIDs?
After the replies I received thus far, I tried this:
Dim src = loanTable.AsEnumerable().ToLookup(x >= x.bSSN, x >= x)
and got an error on ToLookup(). "Overload resolution failed because no accessible 'ToLookup' can be called with these arguments (Type parameter 'TKey' cannot be inferred). In addition, the 'x' in ToLookup(x => x.UserID, x => x) returns an error that 'x' is not declared.