I have a Linq query which returns all of the data stored in a table based on a where clause as a list:
List<Catalogue> data = context.Catalogue.Where(x=>x.ManID == id).ToList();
This returns 23 items, but some of those items have some columns which contains duplicate data, I'll call them ColumnA, ColumnB and ColumnD. I've tried:
List<Catalogue> data = context.Catalogue.Where(x=>x.ManID == id)
.Distinct().ToList();
But this just returns the same 23 rows. What I'd like is if I could specify the columns I want to have distinct values, something like:
List<Catalogue> data = context.Catalogue.Where(x=>x.ManID == id)
.Distinct(x=> new { x.ColumnA, x.ColumnB, x.ColumnD }).ToList();
Is this possible or should I look for a new way of doing this?