Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

GroupBy on Mutiple Columns of an AsEnumerable DataTable

$
0
0

Is it possible to have a Linq GroupBy that specifies multiple columns in an AsEnumerable DataTable.  I have successfully grouped based on a single column using s.Field<string>(colName) as the GroupBy parameter, but can't find a way to specify multiple columns.   See the desired code below.  Thanks.

string col1 = "col name 1";
string col2 = "col Name 2";

var myDataTableAE = myDataTable.AsEnumerble();
var group = myDataTableAE..GroupBy(s => new { s.Field<string>(col1), s.Field<string>(col2) })
.Where(g => g.Count() > 1)
.ToList();


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>