
If I write query to fetch City column values:
- public JsonResult getEmpCity()
- {
- using (CompanyDBEntities dc = new CompanyDBEntities())
- {
- var query = (from p in dc.Emp_Information
- select p.City).ToList();
- return new JsonResult
- {
- Data = query.ToList(),
- JsonRequestBehavior = JsonRequestBehavior.AllowGet
- };
- }
- }

Now write your code like below:
- public JsonResult getEmpCity()
- {
- using (CompanyDBEntities dc = new CompanyDBEntities())
- {
- var query = (from p in dc.Emp_Information
- select p.City).Distinct().ToList();
- return new JsonResult
- {
- Data = query.ToList(),
- JsonRequestBehavior = JsonRequestBehavior.AllowGet
- };
- }
- }



Rajesh KumarPosted Jun 13, 2018, 1:12 AM EDT
Good information, will be useful ....
Pradeep SahooPosted May 18, 2016, 12:52 PM EDT
Nice share .........
Bhuvanesh MohankumarPosted May 6, 2016, 11:51 AM EDT
Good one...
Muhammad Aqib ShehzadPosted Apr 21, 2016, 9:31 AM EDT
nice one