public virtual async Task <ResponseResult <PageModel <T> > > SearchQuery <T, TService>(DataTableOption query) where T : class where TService : IBaseService
        {
            var service = HttpContext.RequestServices.GetService <TService>();
            var result  = new ResponseResult <PageModel <T> >();
            //var pagin = new PageModel<T> { PageSize = query.Length, Page = query.Start / query.Length };
            var expression = query.AsExpression <T>();
            var order      = query.GetOrderBy <T>();

            result.Data = await service.QueryPage(expression, query.PageIndex, query.PageSize, order, query.IncludePaths);

            return(result);
        }
Пример #2
0
        public virtual IActionResult GetList(DataTableOption query)
        {
            var pagin = new Pagination {
                PageSize = query.Length, PageIndex = query.Start / query.Length
            };
            var expression = query.AsExpression <LanguageEntity>();
            var order      = query.GetOrderBy <LanguageEntity>();

            if (order != null)
            {
                if (query.IsOrderDescending())
                {
                    pagin.OrderByDescending = order;
                }
                else
                {
                    pagin.OrderBy = order;
                }
            }
            var entities = _languageService.Get(expression, pagin);

            return(Json(new TableData(entities, pagin.RecordCount, query.Draw)));
        }