
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, 5:12 AM
Good information, will be useful ....
Pradeep SahooPosted May 18, 2016, 4:52 PM
Nice share .........
Bhuvanesh MohankumarPosted May 6, 2016, 3:51 PM
Good one...
Muhammad Aqib ShehzadPosted Apr 21, 2016, 1:31 PM
nice one