Assuming the
IDtoEdit
is the primary key of the entity, and you only want to return the matching item, use
Find
:
using (var db = new EBContext())
{
var results = new List<object>();
var item = db.Set(tableType).Find(IDtoEdit);
if (item != null) results.Add(item);
return Json(results, JsonRequestBehavior.AllowGet);
}
DbSet.Find Method (Object[]) (System.Data.Entity)[
^]