多条件查询判断

it2022-05-17  64

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

}

转载于:https://www.cnblogs.com/MenBe/p/9521714.html


最新回复(0)