Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LINQ - Group DataTable by multiple columns determined at runtime
- // column source
- IEnumerable<string> columns;
- DataTable table;
- IEnumerable<IGrouping<object, DataRow>> groupings = table
- .AsEnumerable()
- .GroupBy(row => ???);
- Func<DataRow, IEnumerable<string>, string> f = (row, cols) =>
- String.Join("|", cols.Select(col => row[col]));
- IEnumerable<IGrouping<object, DataRow>> groupings = table
- .AsEnumerable()
- .GroupBy(row => f(row, columns));
Add Comment
Please, Sign In to add comment