This question is locked. New answers and comments are not allowed.
Hi All.
I have Dynamic Data table and i want to extract Distinct Rows Based on certain number of Columns
Now number of Columns is dynamic
I am trying to use LINQ to achieve this
I am using
var distinctRows = (from DataRow dRow in dt.Rows
select new {col1 = dRow["T0"], col2 = dRow["T1"], col3 = dRow["T2"], col4 = dRow["T3"] }).Distinct();
------------------(T0,T1,T2,T3) are Column Names--------
where this Datatable has 4 columns on which i need Distinct query but i need a generic solution where Number of Columns Can be flexible??
For Example if i need to Fire Distinct query for Five Columns query will become
and So on ...
how can i make this query flexible??
Any help??
Thanks
I have Dynamic Data table and i want to extract Distinct Rows Based on certain number of Columns
Now number of Columns is dynamic
I am trying to use LINQ to achieve this
I am using
var distinctRows = (from DataRow dRow in dt.Rows
select new {col1 = dRow["T0"], col2 = dRow["T1"], col3 = dRow["T2"], col4 = dRow["T3"] }).Distinct();
------------------(T0,T1,T2,T3) are Column Names--------
where this Datatable has 4 columns on which i need Distinct query but i need a generic solution where Number of Columns Can be flexible??
For Example if i need to Fire Distinct query for Five Columns query will become
var distinctRows = (from DataRow dRow in dt.Rows
select new {col1 = dRow["T0"], col2 = dRow["T1"], col3 = dRow["T2"],
col4 = dRow["T3"] , col5 = dRow["T4"]}).Distinct();
and So on ...
how can i make this query flexible??
Any help??
Thanks