Entity Framework chooses a unique name

c# distinct entity-framework linq

Question

How should I proceed?SQL search withEntity Framework ?

SELECT DISTINCT NAME FROM TestAddresses
1
131
8/16/2019 8:07:04 PM

Accepted Answer

lambda expression use

 var result = EFContext.TestAddresses.Select(m => m.Name).Distinct();
259
12/27/2010 3:36:19 PM

Popular Answer

Do this:

var results = (from ta in context.TestAddresses
               select ta.Name).Distinct();

This provides you with anIEnumerable<string> - You may dial.ToList() to it to get aList<string> .



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow