在 Controller (ASP.Net MVC) 中使用 ViewBag 和 SelectList 以及 LINQ 在 WHERE 子句中添加 AND
Adding AND in a WHERE clause using ViewBag and SelectList with LINQ in Controller (ASP.Net MVC)
如何在当前 ViewBag
中添加第二个 WHERE
子句 ('AND'),在 Controller
中添加 LINQ
?谢谢!
ViewBag.Subjects = new SelectList(_odb.SUBJ_MSTR.
Where(o => o.TYPE== "4").OrderBy(o => o.SUBJ_NAME), "SUBJ_ID", "SUBJ_VAL");
您可以像这样添加 &&
和 WHERE
。
ViewBag.Subjects = new SelectList(_odb.SUBJ_MSTR.
Where(o => o.TYPE== "4" && o.TYPE=="5").OrderBy(o => o.SUBJ_NAME), "SUBJ_ID", "SUBJ_VAL");
如何在当前 ViewBag
中添加第二个 WHERE
子句 ('AND'),在 Controller
中添加 LINQ
?谢谢!
ViewBag.Subjects = new SelectList(_odb.SUBJ_MSTR.
Where(o => o.TYPE== "4").OrderBy(o => o.SUBJ_NAME), "SUBJ_ID", "SUBJ_VAL");
您可以像这样添加 &&
和 WHERE
。
ViewBag.Subjects = new SelectList(_odb.SUBJ_MSTR.
Where(o => o.TYPE== "4" && o.TYPE=="5").OrderBy(o => o.SUBJ_NAME), "SUBJ_ID", "SUBJ_VAL");