コード例 #1
0
        private static Func <IQueryable <Brand>, IOrderedQueryable <Brand> > OrderBy(BrandSortOrder sortOrder)
        {
            Func <IQueryable <Brand>, IOrderedQueryable <Brand> > orderBy = null;

            switch (sortOrder)
            {
            default:
                //orderBy = v => v.OrderByDescending(s => s);
                break;
            }

            return(orderBy);
        }
コード例 #2
0
 public List <BrandEntity> GetPagedList(PagerRequest pagerRequest, out int totalCount, BrandSortOrder sortOrder)
 {
     return(base.Get(Filler(DataStatus.Normal), out totalCount, pagerRequest.PageIndex, pagerRequest.PageSize, OrderBy(sortOrder)).ToList());
 }
コード例 #3
0
        /// <summary>
        ///  分页
        /// </summary>
        /// <param name="pagerRequest"></param>
        /// <param name="totalCount"></param>
        /// <param name="filter"></param>
        /// <param name="sortOrder"></param>
        /// <returns></returns>
        public List <Brand> GetPagedList(PagerRequest pagerRequest, out int totalCount, BrandFilter filter, BrandSortOrder sortOrder)
        {
            var brandFilter   = Filter(filter);
            var fi            = Filter4SectionBrand(filter);
            var sectionFilter = Filter4Section(filter);

            var result = Func(c =>
            {
                int t;

                var q = from s in c.Set <Brand>().AsExpandable().Where(brandFilter)
                        let sb_let = (from sb in c.Set <IMS_SectionBrand>().AsExpandable().Where(fi)
                                      //join s in c.Set<Sse>()
                                      where s.Id == sb.BrandId
                                      select new
                {
                    sb.SectionId
                })
                                     select new
                {
                    s,
                    Sectons = sb_let
                };

                t = q.Count();

                var q1                     = from b in q.OrderBy(v => v.s.Id).Skip(pagerRequest.SkipCount).Take(pagerRequest.PageSize)
                                   let sup = (from s in c.Set <OpcSupplierInfo>()
                                              join sb in c.Set <Supplier_Brand>() on s.Id equals sb.Supplier_Id
                                              where sb.Brand_Id == b.s.Id
                                              select new OpcSupplierInfoClone
                {
                    Address = s.Address,
                    Contact = s.Contact,
                    Corporate = s.Corporate,
                    Contract = s.Contract,
                    CreatedDate = s.CreatedDate,
                    CreatedUser = s.CreatedUser,
                    FaxNo = s.FaxNo,
                    Id = s.Id,
                    Memo = s.Memo,
                    Status = s.Status,
                    StoreId = s.StoreId,
                    SupplierName = s.SupplierName,
                    SupplierNo = s.SupplierNo,
                    TaxNo = s.TaxNo,
                    Telephone = s.Telephone,
                    UpdatedDate = s.UpdatedDate,
                    UpdatedUser = s.UpdatedUser,
                })

                                             let se = (from s in c.Set <Section>().AsExpandable().Where(sectionFilter)
                                                       join s_b in c.Set <IMS_SectionBrand>().AsExpandable() on s.Id equals s_b.SectionId
                                                       where (s_b.BrandId == b.s.Id)
                                                       select new SectionClone
                {
                    BrandId = s.BrandId,
                    ChannelSectionId = s.ChannelSectionId,
                    ContactPerson = s.ContactPerson,
                    ContactPhone = s.ContactPhone,
                    CreateDate = s.CreateDate,
                    CreateUser = s.CreateUser,
                    Id = s.Id,
                    Location = s.Location,
                    Name = s.Name,
                    Status = s.Status,
                    StoreCode = s.StoreCode,
                    StoreId = s.StoreId,
                    UpdateDate = s.UpdateDate,
                    UpdateUser = s.UpdateUser,
                    SectionCode = s.SectionCode
                })
                                                      select new BrandClone()
                {
                    ChannelBrandId = b.s.ChannelBrandId,
                    CreatedDate    = b.s.CreatedDate,
                    CreatedUser    = b.s.CreatedUser,
                    Description    = b.s.Description,
                    EnglishName    = b.s.EnglishName,
                    Group          = b.s.Group,
                    Id             = b.s.Id,
                    Logo           = b.s.Logo,
                    Name           = b.s.Name,
                    Sections       = se,
                    Status         = b.s.Status,
                    Suppliers      = sup,
                    UpdatedDate    = b.s.UpdatedDate,
                    UpdatedUser    = b.s.UpdatedUser,
                    WebSite        = b.s.WebSite
                };

                var rst = q1.ToList();

                return(new
                {
                    totalCount = t,
                    Data = rst
                });
            });

            totalCount = result.totalCount;

            return(AutoMapper.Mapper.Map <List <BrandClone>, List <Brand> >(result.Data));
        }