예제 #1
0
        public async Task <T> Get(Guid id)
        {
            using (InventoryManagerDbContext context = _contextFactory.CreateDbContext())
            {
                T entity = await context.Set <T>().FirstOrDefaultAsync((e) => e.id == id);

                return(entity);
            }
        }
예제 #2
0
        public async Task <T> Create(T entity)
        {
            using (InventoryManagerDbContext context = _contextFactory.CreateDbContext())
            {
                EntityEntry <T> createdResult = await context.Set <T>().AddAsync(entity);

                await context.SaveChangesAsync();

                return(createdResult.Entity);
            }
        }