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)); }
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()); }