/// <summary> /// 分页查询 /// </summary> /// <param name="condition">查询条件</param> /// <returns></returns> public IEnumerable <SysUser> Seach(SysUserCondition.Search condition) { var page = new Pager <SysUserCondition.Search>() { Condition = condition, Table = "sys_user", Key = "user_id", Order = string.Empty, Field = "*", WhereAction = (Condition, Where, Paramters) => { if (!string.IsNullOrEmpty(Condition.UserName)) { Where.Append("AND user_name LIKE @user_name "); Paramters.Add(base.CreateParameter("@user_name", string.Concat("%", Condition.UserName, "%"))); } if (!string.IsNullOrEmpty(Condition.UserEmail)) { Where.Append("AND user_email LIKE @user_email "); Paramters.Add(base.CreateParameter("@user_email", string.Concat("%", Condition.UserEmail, "%"))); } if (!string.IsNullOrEmpty(Condition.UserMobile)) { Where.Append("AND user_mobile LIKE @user_mobile "); Paramters.Add(base.CreateParameter("@user_mobile", string.Concat("%", Condition.UserMobile, "%"))); } } }; var result = base.GetResultByPager <SysUser, SysUserCondition.Search>(page); return(result); }
/// <summary> /// 分页查询 /// </summary> /// <param name="condition">查询条件</param> /// <returns></returns> public IEnumerable <SysUser> UnionSeach(SysUserCondition.Search condition) { var page = new Pager <SysUserCondition.Search>() { Condition = condition, UnionText = @"WITH alluser AS ( SELECT * FROM sys_user UNION ALL SELECT * FROM sys_user )", Table = "alluser", Order = string.Empty, Field = "*", WhereAction = (Where, Paramters) => { if (!string.IsNullOrEmpty(condition.UserName)) { Where.Append("AND user_name LIKE @user_name "); Paramters.Add(base.CreateParameter("@user_name", string.Concat("%", condition.UserName, "%"))); } if (!string.IsNullOrEmpty(condition.UserEmail)) { Where.Append("AND user_email LIKE @user_email "); Paramters.Add(base.CreateParameter("@user_email", string.Concat("%", condition.UserEmail, "%"))); } if (!string.IsNullOrEmpty(condition.UserMobile)) { Where.Append("AND user_mobile LIKE @user_mobile "); Paramters.Add(base.CreateParameter("@user_mobile", string.Concat("%", condition.UserMobile, "%"))); } } }; var result = base.GetResultByPager <SysUser, SysUserCondition.Search>(page); return(result); }