コード例 #1
0
        public override async Task <DAL.App.DTO.ClientGroup> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var clientGroup = await RepositoryDbSet.FindAsync(id);

            if (clientGroup != null)
            {
                await RepositoryDbContext.Entry(clientGroup)
                .Collection(c => c.Clients)
                .LoadAsync();

                await RepositoryDbContext.Entry(clientGroup)
                .Reference(c => c.Name)
                .LoadAsync();

                await RepositoryDbContext.Entry(clientGroup.Name)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(clientGroup)
                .Reference(c => c.Description)
                .LoadAsync();

                await RepositoryDbContext.Entry(clientGroup.Description)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();
            }

            return(ClientGroupMapper.MapFromDomain(clientGroup));
        }
コード例 #2
0
ファイル: ClientRepository.cs プロジェクト: iiristakel/garage
        public async Task <List <ClientWithProductsCount> > GetAllWithProductsCountAsync()
        {
            return(await RepositoryDbSet
                   .Include(p => p.ClientGroup)
                   .ThenInclude(p => p.Name)
                   .ThenInclude(t => t.Translations)
                   .Include(p => p.ClientGroup)
                   .ThenInclude(p => p.Description)
                   .ThenInclude(t => t.Translations)

                   .Select(c => new ClientWithProductsCount()
            {
                Id = c.Id,
                ClientGroup = ClientGroupMapper.MapFromDomain(c.ClientGroup),
                ClientGroupId = c.ClientGroupId,
                ProductsCount = c.ProductsForClient.Count,
                CompanyName = c.CompanyName,
                Address = c.Address,
                Phone = c.Phone,
                ContactPerson = c.ContactPerson
            })
                   .ToListAsync());
        }
コード例 #3
0
 public async Task <List <BLL.App.DTO.ClientGroupWithClientCount> > GetAllWithClientCountAsync()
 {
     return((await Uow.ClientGroups.GetAllWithClientCountAsync())
            .Select(e => ClientGroupMapper.MapFromDAL(e))
            .ToList());
 }