Пример #1
0
        public override Query <T> Paging(int pageIndex, int pageSize, Expression <Func <T, object> > sort_field = null, string sortWay = null, Expression <Func <T, object> > sort_field1 = null, string sortWay1 = null)
        {
            pageIndex = pageIndex <= 0 ? 1 : pageIndex;
            var    PagingSql = new StringBuilder();
            string sort_str  = sort_field == null ? string.Empty : $" ORDER BY {ReflectionExtension.GetProperty(sort_field).Name} {sortWay}";

            PagingSql.Append(sort_str);
            sort_str = sort_field1 == null ? string.Empty : $" ,{ReflectionExtension.GetProperty(sort_field1).Name} {sortWay1}";
            PagingSql.Append(sort_str);

            PagingSql.Append($" LIMIT { (pageIndex - 1) * pageSize},{pageSize}");

            _sqlPaging = new SqlPaging(PagingSql.ToString());
            return(this);
        }
Пример #2
0
        public override Query <T> Paging(int pageIndex, int pageSize, Expression <Func <T, object> > sort_field = null, string sortWay = null, Expression <Func <T, object> > sort_field1 = null, string sortWay1 = null)
        {
            pageIndex = pageIndex <= 0 ? 1 : pageIndex;
            var    PagingSql = new StringBuilder();
            string sort_str  = sort_field == null ? string.Empty : $" ORDER BY {ReflectionExtension.GetProperty(sort_field).Name} {sortWay}";

            PagingSql.Append(sort_str);
            sort_str = sort_field1 == null ? string.Empty : $" ,{ReflectionExtension.GetProperty(sort_field1).Name} {sortWay1}";
            PagingSql.Append(sort_str);

            if (sort_field == null && sort_field1 == null)
            {
                string CountKey = this.propertyMaps.First(m => m.PrimaryKey != null).Name;
                PagingSql.Append($" ORDER BY {CountKey} ");
            }

            PagingSql.Append($" OFFSET { (pageIndex - 1) * pageSize} ROWS FETCH NEXT {pageSize} ROWS ONLY");

            _sqlPaging = new SqlPaging(PagingSql.ToString());
            return(this);
        }