Home > DeveloperSection > Forums > How to find select distinct Address in Entity Framework
Simond Gear
Simond Gear

Total Post:12

Points:84
Posted on    March-19-2016 12:21 AM

 ASP.NET MVC C#  ASP.Net  Mvc  Entity Framework 
Ratings:


 1 Reply(s)
 450  View(s)
Rate this:
Hi All,

I want to access all distinct 'Address'  in Employee Table. My code is below:

SELECT DISTINCT Address FROM Employee

But i am not get correct output .Can any one give me a solution.

Thank you.



Anupam Mishra

Total Post:135

Points:949
Posted on    March-19-2016 12:26 AM

Hi Simond,

you try this:

               var res = (from Add in context.Employee 
                                            select Add .Address).Distinct();
It will returns  IEnumerable<string>. you can convert List<string> by adding  .ToList().

Modified On Mar-19-2016 12:26:43 AM

Don't want to miss updates? Please click the below button!

Follow MindStick