How can I return all the columns of a table using multiple distinct columns in linq. I need to return all columns of a table with multiple distincts?
Thanks
How can I return all the columns of a table using multiple distinct columns in linq. I need to return all columns of a table with multiple distincts?
Thanks
You want to use GroupBy:
var distinctModelYears = cars.GroupBy(c => new { c.Year, c.Model })
.Select(g => g.First()) //Take one from each group
;
That will find all "distinct" years and models so there will only be one 2008 Accord, one 2009 Accord, etc.