Hello All. I am sure I am overlooking something but...could someone assist please. I am simply trying to select DISTINCT using the following code....and it is returning a all (even duplicates. Thank you for any assistance.
public JsonResult GetCounties(string statename)
{
var counties = db.Counties.AsQueryable();
if (statename != null)
{
counties = counties.Distinct().Where(c => c.StateName == statename);
}
return Json(counties.Select(p => new { CountyId = p.CountyId, CountyName = p.CountyName }), JsonRequestBehavior.AllowGet);
}