Пример #1
0
        /// <summary>
        ///获取卡券分页数据
        /// </summary>
        /// <param name="custId">商户Id</param>
        /// <param name="title">卡券名称</param>
        /// <param name="cardType">卡券类型(CASH:代金券,DISCOUNT:折扣券,GIFT:兑换券,GROUPON:团购券)</param>
        /// <param name="status">卡券状态(0:待审核,1:审核中,2:审核通过,2:审核未通过,3:待投放,4:已投放,5:下架)</param>
        /// <param name="orderColumn">排序列</param>
        /// <param name="orderBy">排序类型</param>
        /// <param name="offset">开始位置</param>
        /// <param name="pageRows">每页显示记录数</param>
        /// <param name="totalRows">总记录数</param>
        /// <returns>the list of query result.</returns>
        public IEnumerable <MarCard> GetPaggingList(int custId, string title, string cardType, byte?status, string orderColumn, ListResultsOrder orderBy, int?offset, int?pageRows, out int totalRows)
        {
            var builder  = new SqlSelectBuilder();
            var template = builder.AddTemplate(new SqlSever2012Template(builder, "SELECT /**select**/", string.Format("FROM  {0}  /**where**/", TableName), "/**orderby**/", null));

            builder.Select("*");
            builder.Where("CustId=@CustId", new { CustId = custId });
            if (!string.IsNullOrEmpty(title))
            {
                title = "%" + title + "%";
                builder.Where("Title LIKE @Title", new { Title = title });
            }
            if (!string.IsNullOrEmpty(cardType))
            {
                builder.Where("CardType = @CardType", new { CardType = cardType });
            }
            if (status.HasValue)
            {
                builder.Where("Status = @Status", new { Status = status.Value });
            }
            return(base.GetPaggingList(Conn, builder, template, orderColumn, orderBy, offset, pageRows, out totalRows));
        }