How to convert this IQueryable <Patient> to DbSet <Patient>?
It should be simple, but I worked on the line inside the IF block. Error on this line
"It is not possible to implicitly convert the type 'System.Linq.IQueryable [Patient]' to 'System.Data.Entity.DbSet [Patient]. An explicit conversion exists (do you miss the role?)"
I tried to add many extensions ( AsQueryable()
, ToList()
, AsEnumerable()
, etc.) after .Contains()
no avail.
What am I missing here? This project is created using the beta version of MVC 4 and EF4
public ActionResult SearchIndex(string searchString) { var patients = this.db.Patients; if (!String.IsNullOrEmpty(searchString)) { patients = patients.Where(p => p.LastName.Contains(searchString)); } return View(patients.ToList()); }
+6