How do I convert this IQueryable<Patient> to DbSet<Patient> ?
.net-4.0, asp.net-mvc, entity-framework
Solution
Declare patients explicitly as `IQueryable<Patient>`
IQueryable<Patient> patients = this.db.Patients;
Or call `AsQueryable` on it:
var patients = this.db.Patients.AsQueryable();
Problem
This should be straightforward but I'm getting tripped up on the line inside the IF block. The error on that line is "Cannot implicitly convert type 'System.Linq.IQueryable[Patient]' to 'System.Data.Entity.DbSet[Patient]'. An explicit conversion exists (are you missing a cast?)" I tried appending a variety of extensions (`AsQueryable()`, `ToList()`, `AsEnumerable()`, etc) after `.Contains()` to no avail. What am I missing here? This project is build using the MVC 4 Beta 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()); } ```