public List <Section> GetPagedList(PagerRequest pagerRequest, out int totalCount, SectionFilter filter, SectionSortOrder sortOrder)
        {
            var sectionbrandFilter = Filter4SectionBrand(filter);
            var sectionFilter      = Filter(filter);
            var brandFilter        = Filter4Brand(filter);

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

                var qt = from s in c.Set <Section>().AsExpandable().Where(sectionFilter)
                         join store in c.Set <Store>() on s.StoreId equals store.Id into tmp1
                         from store in tmp1.DefaultIfEmpty()

                         let s_b_let = (from sb in c.Set <IMS_SectionBrand>().AsExpandable().Where(sectionbrandFilter)
                                        where s.Id == sb.SectionId
                                        select new
                {
                    sb.SectionId
                }
                                        )

                                       select new
                {
                    section = s,
                    sbs     = s_b_let,
                    Store   = store == null ? null : store
                };

                t = qt.Count();

                var qr = from s in qt.OrderBy(v => v.section.Id).Skip(pagerRequest.SkipCount).Take(pagerRequest.PageSize)

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


                return(new
                {
                    totalCount = t,
                    Data = qr.ToList()
                });
            });

            totalCount = result.totalCount;

            return(AutoMapper.Mapper.Map <List <SectionClone>, List <Section> >(result.Data));
        }
        private static Func <IQueryable <Section>, IOrderedQueryable <Section> > OrderBy(SectionSortOrder sortOrder)
        {
            Func <IQueryable <Section>, IOrderedQueryable <Section> > orderBy = null;

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

            return(orderBy);
        }