Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public IEnumerable <MySqlUser> Seach(MySqlUserCondition.Search condition)
        {
            var page = new Pager <MySqlUserCondition.Search>()
            {
                Condition   = condition,
                UnionText   = @"
                            SELECT * FROM t_d_user
                            UNION ALL
                            SELECT * FROM t_d_user",
                Table       = "alluser",
                Key         = "id",
                Order       = string.Empty,
                Field       = "*",
                WhereAction = (Condition, Where, Paramters) =>
                {
                    if (Condition.Id > 0)
                    {
                        Where.Append("AND ID = :ID ");
                        Paramters.Add(base.CreateParameter(":ID", Condition.Id));
                    }
                }
            };

            var result = base.GetResultByPager <MySqlUser, MySqlUserCondition.Search>(page);

            return(result);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 添加参数
 /// </summary>
 /// <param name="paramter"></param>
 /// <returns></returns>
 public DbQuery AddParam(DbParameter paramter)
 {
     if (paramter != null)
     {
         Paramters.Add(paramter);
     }
     return(this);
 }
Exemplo n.º 4
0
        /// <summary>
        /// 添加参数
        /// </summary>
        /// <param name="name"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public DbQuery AddParam(string name, object value)
        {
            var param = Command.CreateParameter();

            param.ParameterName = name;
            param.Value         = value;
            Paramters.Add(param);
            return(this);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public IEnumerable <OracleUser> Seach(OracleUserCondition.Search condition)
        {
            var page = new Pager <OracleUserCondition.Search>()
            {
                Condition   = condition,
                Table       = "t_d_user",
                Order       = string.Empty,
                Field       = "*",
                WhereAction = (Where, Paramters) =>
                {
                    if (condition.Id > 0)
                    {
                        Where.Append("AND ID = :ID ");
                        Paramters.Add(base.CreateParameter(":ID", condition.Id));
                    }
                }
            };

            var result = base.GetResultByPager <OracleUser, OracleUserCondition.Search>(page);

            return(result);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public IEnumerable <ShtSacrifice> Seach(ShtSacrificeCondition.Search condition)
        {
            var page = new Pager <ShtSacrificeCondition.Search>
            {
                Condition   = condition,
                Table       = "sht_sacrifice a",
                Order       = "a.scfe_createtime DESC",
                Field       = "*",
                WhereAction = (Where, Paramters) =>
                {
                    if (!string.IsNullOrWhiteSpace(condition.ScfeName))
                    {
                        Paramters.Add(base.CreateParameter("@scfe_name", string.Concat("%", condition.ScfeName, "%")));
                        Where.Append("AND a.scfe_name LIKE @scfe_name ");
                    }

                    if (!string.IsNullOrWhiteSpace(condition.ScfeUnitName))
                    {
                        Paramters.Add(base.CreateParameter("@scfe_unit_name", string.Concat("%", condition.ScfeUnitName, "%")));
                        Where.Append("AND a.scfe_unit_name LIKE @scfe_unit_name ");
                    }

                    if (condition.ScfeCateId != null && condition.ScfeCateId.Value > 0)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_cate_id", condition.ScfeCateId.Value));
                        Where.Append("AND a.scfe_cate_id = @scfe_cate_id ");
                    }

                    if (!string.IsNullOrWhiteSpace(condition.ScfeCateName))
                    {
                        Paramters.Add(base.CreateParameter("@scfe_cate_name", string.Concat("%", condition.ScfeCateName, "%")));
                        Where.Append("AND a.scfe_cate_name LIKE @scfe_cate_name ");
                    }

                    if (!string.IsNullOrWhiteSpace(condition.ScfeImage))
                    {
                        Paramters.Add(base.CreateParameter("@scfe_image", string.Concat("%", condition.ScfeImage, "%")));
                        Where.Append("AND a.scfe_image LIKE @scfe_image ");
                    }

                    if (condition.ScfePrice != null && condition.ScfePrice.Value > 0)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_price", condition.ScfePrice.Value));
                        Where.Append("AND a.scfe_price = @scfe_price ");
                    }

                    if (condition.ScfeGold != null && condition.ScfeGold.Value > 0)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_gold", condition.ScfeGold.Value));
                        Where.Append("AND a.scfe_gold = @scfe_gold ");
                    }

                    if (condition.ScfeStatus != null && condition.ScfeStatus.Value > 0)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_status", condition.ScfeStatus.Value));
                        Where.Append("AND a.scfe_status = @scfe_status ");
                    }

                    if (condition.ScfeUpdatetimeBegin != null)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_updatetime_begin", condition.ScfeUpdatetimeBegin.Value.ToString("yyyy-MM-dd HH:mm:ss")));
                        Where.Append(" AND a.scfe_updatetime >= @scfe_updatetime_begin ");
                    }
                    if (condition.ScfeUpdatetimeEnd != null)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_updatetime_end", condition.ScfeUpdatetimeEnd.Value.ToString("yyyy-MM-dd HH:mm:ss")));
                        Where.Append(" AND a.scfe_updatetime <= @scfe_updatetime_end ");
                    }

                    if (condition.ScfeCreatetimeBegin != null)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_createtime_begin", condition.ScfeCreatetimeBegin.Value.ToString("yyyy-MM-dd HH:mm:ss")));
                        Where.Append(" AND a.scfe_createtime >= @scfe_createtime_begin ");
                    }
                    if (condition.ScfeCreatetimeEnd != null)
                    {
                        Paramters.Add(base.CreateParameter("@scfe_createtime_end", condition.ScfeCreatetimeEnd.Value.ToString("yyyy-MM-dd HH:mm:ss")));
                        Where.Append(" AND a.scfe_createtime <= @scfe_createtime_end ");
                    }
                }
            };

            var result = base.GetResultByPager <ShtSacrifice, ShtSacrificeCondition.Search>(page);

            return(result);
        }