سؤال

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