示例#1
0
        public override async Task <List <DAL.App.DTO.Show> > AllAsync()
        {
            return(await RepositoryDbSet
                   .Include(m => m.Title)
                   .ThenInclude(t => t.Translations)
                   .Include(n => n.Comment)
                   .ThenInclude(t => t.Translations)
                   .Include(n => n.Location)
                   .ThenInclude(a => a.Locations)
                   .ThenInclude(t => t.Translations)

                   .Select(e => ShowMapper.MapFromDomain(e)).ToListAsync());
        }
示例#2
0
        public override async Task <DTO.Show> FindAsync(params object[] id)
        {
            var culture = Thread.CurrentThread.CurrentUICulture.Name.Substring(0, 2).ToLower();

            var show = await RepositoryDbSet.FindAsync(id);

            if (show != null)
            {
                await RepositoryDbContext.Entry(show)
                .Reference(c => c.Title)
                .LoadAsync();

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

                await RepositoryDbContext.Entry(show)
                .Reference(c => c.Location)
                .LoadAsync();

                await RepositoryDbContext.Entry(show.Location)
                .Reference(c => c.Locations)
                .LoadAsync();

                await RepositoryDbContext.Entry(show.Location.Locations)
                .Collection(b => b.Translations)
                .Query()
                .Where(t => t.Culture == culture)
                .LoadAsync();

                await RepositoryDbContext.Entry(show)
                .Reference(c => c.Comment)
                .LoadAsync();

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

            return(ShowMapper.MapFromDomain(show));
        }