コード例 #1
0
        public async Task <Result <List <CompanyInfoDTO> > > GetAllCompanyAsync(SearchModel searchModel)
        {
            searchModel.FixPageDefinations();
            IQueryable <Company> source = _unitOfWork.EntityRepository <Company>().GetQueryable((Company w) => w.IsDeleted == false, null);

            if (!string.IsNullOrEmpty(searchModel.SearchText))
            {
                source = from w in source
                         where w.Name.Contains(searchModel.SearchText)
                         select w;
            }
            return(Result.Data(await EntityFrameworkQueryableExtensions.ToListAsync <CompanyInfoDTO>(from s in (from o in source
                                                                                                                orderby o.Name
                                                                                                                select o).Skip(searchModel.PageSize * searchModel.PageIndex).Take(searchModel.PageSize)
                                                                                                     select new CompanyInfoDTO
            {
                Id = s.Id,
                Name = s.Name,
                Image = s.Image
            }, default(CancellationToken))));
        }