码迷,mamicode.com
首页 > 其他好文 > 详细

多条件查询判断

时间:2018-08-23 10:09:46      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:action   ret   public   where   empty   space   model   white   cti   

/// <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);

}

多条件查询判断

标签:action   ret   public   where   empty   space   model   white   cti   

原文地址:https://www.cnblogs.com/MenBe/p/9521714.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!