Example #1
0
        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);
        }
Example #2
0
 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());
        }
Example #4
0
 public List <T> GetAll()
 {
     return(_db.Set <T>().ToList());
 }
Example #5
0
 public EfRepository(DictionaryContext context)
 {
     _context = context;
     _dbSet   = context.Set <TEntity>();
 }