문제

Actually I want to get the full table but it should be based on Doc_Type==distinct

Means it should only pick the records from table that has unique Doc_Type. I have tried with following but it returns me a single column into tolist() but I want to get full table. How can I do it?

var data = DB.tblDocumentTypes.Select(m => m.Doc_Type).Distinct().ToList();
도움이 되었습니까?

해결책

You can use GroupBy

 var data = DB.tblDocumentTypes.GroupBy(m => m.Doc_Type).Select(x => x.First());
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top