I want to use the distinct clause for multiple levels. Firstly i tried with DataTable but did't got success so i converted DataTable to AsEnumerable.
My problem here is that the Fields which i have specified/hard coded will be coming dynamic, same for both Where & Select.
How to add dynamic Fields in Where
& Select
?
DataTable data3 = new DataTable();
var listData = data3.AsEnumerable()
.Where(m => !String.IsNullOrEmpty(m.Field<string>("clientname"))
&& !String.IsNullOrEmpty(m.Field<string>("project"))
&& !String.IsNullOrEmpty(m.Field<string>("postedstate"))
&& !String.IsNullOrEmpty(m.Field<string>("postedcity"))
&& !String.IsNullOrEmpty(m.Field<string>("siteadd")))
.Select(row => new
{
clientname = row.Field<string>("clientname"),
project = row.Field<string>("project"),
postedstate = row.Field<string>("postedstate"),
postedcity = row.Field<string>("postedcity"),
siteadd = row.Field<string>("siteadd")
}).Distinct();