三种解决方案
1多条件查询技巧ado.net
2ef组合查询
3dapper组合查询
ef组合查询
http://www.xuebuyuan.com/128577.html
http://blog.csdn.net/limlimlim/article/details/8638080
多条件查询--使用dapper命令参数动态拼接出最安全的sql语句
http://www.lanhusoft.com/Article/128.html
- publicList<MSys_Admin>GetAdminList(MSys_Admin model)
- {
- string sqlText ="select count(1) from Sys_Admin where 1=1";
- var p =newDynamicParameters();
- if(!string.IsNullOrEmpty(model.LoginName))
- {
- sqlText +=" and LoginName like @LoginName";
- p.Add("LoginName", model.LoginName+"%");
- }
- if(!string.IsNullOrEmpty(model.Name))
- {
- sqlText +=" and Name like @Name";
- p.Add("Name","%"+ model.Name+"%");
- }
- using(var conn =Common.GetConn())
- {
- conn.Open();
- var r = conn.Query<MSys_Admin>(sqlText, p);
- conn.Close();
- return r.ToList();
- }
- }
原文参考:http://note.youdao.com/share/?id=3961b32ccfefd04d36c23fba0dc05a6d&type=note
时间: 2024-10-15 14:08:02