public void Setup() { var optionsBuilder = new DbContextOptionsBuilder <DictionaryContext>(); optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Lingva;Trusted_Connection=True;MultipleActiveResultSets=true;"); var _dbContext = new DictionaryContext(optionsBuilder.Options); _dbContext.Database.EnsureDeleted(); _dbContext.Database.EnsureCreated(); _groupList = new List <Group>() { new Group { Name = "Harry Potter", Date = DateTime.Now, Description = "Description", LanguageId = 1, }, new Group { Name = "Harry Potter", Date = DateTime.Now, Description = "Description", LanguageId = 1, } }; _dbContext.Set <Group>().AddRange(_groupList); _dbContext.SaveChanges(); _groupRepository = new GroupRepository(_dbContext); }
public Repository(DictionaryContext context) { _context = context; _entities = context.Set <T>(); }
public virtual async Task <IEnumerable <T> > GetListAsync <T>() where T : BaseBE, new() { IQueryable <T> result = _dbContext.Set <T>().AsNoTracking(); return(await result.ToListAsync()); }
public List <T> GetAll() { return(_db.Set <T>().ToList()); }
public EfRepository(DictionaryContext context) { _context = context; _dbSet = context.Set <TEntity>(); }