How can I do this SQL
query with Entity Framework
?
SELECT DISTINCT NAME FROM TestAddresses
See Question&Answers more detail:osHow can I do this SQL
query with Entity Framework
?
SELECT DISTINCT NAME FROM TestAddresses
See Question&Answers more detail:osUsing lambda expression..
var result = EFContext.TestAddresses.Select(m => m.Name).Distinct();
Another variation using where,
var result = EFContext.TestAddresses
.Where(a => a.age > 10)//if you have any condition
.Select(m => m.name).Distinct();
Another variation using sql like syntax
var result = (from recordset
in EFContext.TestAddresses
.where(a => a.city = 'NY')//if you have any condition
.select new
{
recordset.name
}).Distinct();