1
我想下面的代碼...如何寫像Linq查詢到實體
public ActionResult Search(string query)
{
using (DbAccess db=new DbAccess())
{
List<Student> studentsList = db.Students.Where(m=>m.name.Contains("d")==query).ToList();
return View(studentsList);
}
}
但是,如果使用「包含」然後它給我的錯誤.. 請幫助
哪個錯誤?這應該出現在你的問題中。 –
'Contains'返回'bool',並且將它與'String'(查詢)進行比較。我相信你正在尋找'db.Students.Where(m => m.name.Contains(「d」)&& m.name == query).ToList()' – Nkosi