public async Task CanCreateUserIntViaSet() { using (var db = new CustomDbContext <int>( new DbContextOptionsBuilder().UseSqlite($"DataSource=D{Guid.NewGuid()}.db").Options)) { db.Database.EnsureCreated(); var user = new User <int>(); var users = db.Set <User <int> >(); users.Add(user); await db.SaveChangesAsync(); user.UserName = "******"; await db.SaveChangesAsync(); var fetch = users.First(u => u.UserName == "Boo"); Assert.Equal(user, fetch); db.Database.EnsureDeleted(); } }
/// <summary> /// Constructor for pass db context /// </summary> /// <param name="db"></param> public GenericRepository(CustomDbContext db) { this.db = db; table = db.Set <T>(); }
/// <summary> /// Constructor /// </summary> public GenericRepository() { this.db = new CustomDbContext(); table = db.Set <T>(); }
public GenericRepository(CustomDbContext context) { dbContext = context; entities = context.Set <TEntity>(); }
public IQueryable <T> GetAll() { return(_context.Set <T>().AsNoTracking()); }
public BaseController(CustomDbContext context) { _context = context; _dbSet = context?.Set <T>(); }