コード例 #1
0
        public Detail[] GetAllByIds(IEnumerable <int> detailIds)
        {
            var dbContext = dbContextFactory.Create(typeof(DetailRepository));

            return(dbContext.Details
                   .Where(detail => detailIds.Contains(detail.Id))
                   .AsEnumerable()
                   .Select(Detail.Mapper.Map)
                   .ToArray());
        }
コード例 #2
0
        public Book[] GetAllByIds(IEnumerable <int> bookIds)
        {
            var dbContex = dbContextFactory.Create(typeof(BookRepository));

            return(dbContex.Books
                   .Where(book => bookIds.Contains(book.Id))
                   .AsEnumerable()
                   .Select(Book.Mapper.Map)
                   .ToArray());
        }
コード例 #3
0
        public async Task <Order> CreateAsync()
        {
            var dbContext = dbContextFactory.Create(typeof(OrderRepository));

            var dto = Order.DtoFactory.Create();

            dbContext.Orders.Add(dto);
            await dbContext.SaveChangesAsync();

            return(Order.Mapper.Map(dto));
        }
コード例 #4
0
        public async Task <Book[]> GetAllByIdsAsync(IEnumerable <int> bookIds)
        {
            var dbContext = dbContextFactory.Create(typeof(BookRepository));

            var dtos = await dbContext.Books
                       .Where(book => bookIds.Contains(book.Id))
                       .ToArrayAsync();

            return(dtos.Select(Book.Mapper.Map)
                   .ToArray());
        }
コード例 #5
0
        public Order Create()
        {
            var dbContex = dbContextFactory.Create(typeof(OrderRepository));

            var dto = Order.DtoFactory.Create();

            dbContex.Orders.Add(dto);
            dbContex.SaveChanges();

            return(Order.Mapper.Map(dto));
        }