多条件查询判断
Posted menbe
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了多条件查询判断相关的知识,希望对你有一定的参考价值。
/// <summary>
/// 查询条件
/// </summary>
/// <param name="name"></param>
/// <param name="xiaoqu"></param>
/// <param name="donghao"></param>
/// <param name="huxing"></param>
/// <param name="zhuangtai"></param>
/// <returns></returns>
public ActionResult Select(string name = "", string xiaoqu = "", string donghao = "", string huxing = "", string zhuangtai = "")
{
XiaoQu();
DongHao();
HuXing();
ZhuangTai();
string where = "";
if (!string.IsNullOrWhiteSpace(name))
{
where += "a.ZuoLuo like ‘%" + name + "%‘";
}
if (!string.IsNullOrEmpty(xiaoqu))
{
where += "and a.XiaoQuID = " + xiaoqu + "";
}
if (!string.IsNullOrWhiteSpace(donghao))
{
where += "and a.DongHao = " + donghao + "";
}
if (!string.IsNullOrWhiteSpace(huxing))
{
where += "and a.HuXingID = " + huxing + "";
}
if (!string.IsNullOrWhiteSpace(zhuangtai))
{
where += "and a.ZhuangTaiID = " + zhuangtai + "";
}
Where = where;
List<UserInfoModel> list = ShowPage();
return View("Index", list);
}
以上是关于多条件查询判断的主要内容,如果未能解决你的问题,请参考以下文章