public void TestInitialize() { var options = new DbContextOptionsBuilder <CustomerDbContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; context = new CustomerDbContext(options); context.Database.EnsureDeleted(); customerRepository = new CustomerRepository(context); customerCollection = context.Set <CustomerDataModel>(); }
public static async Task Seed(CustomerDbContext dbContext) { dbContext.Set <Customer>().Add(new Customer { Id = Guid.NewGuid(), FirstName = "Tuan", LastName = "Manh", ContactTitle = "Mr", AddressInfo = new AddressInfo(Guid.NewGuid(), "123 ABC", "Ho Chi Minh", "", "", "VN"), ContactInfo = new ContactInfo(Guid.NewGuid(), "123456789", "1234567890", "http://tuanmanh.com.vn") }); dbContext.Set <Customer>().Add(new Customer { Id = Guid.NewGuid(), FirstName = "Thang", LastName = "Chung", ContactTitle = "Mr", AddressInfo = new AddressInfo(Guid.NewGuid(), "456 ABC", "Ho Chi Minh", "", "", "VN"), ContactInfo = new ContactInfo(Guid.NewGuid(), "123456789", "1234567890", "http://thangchung.com.vn") }); await dbContext.SaveChangesAsync(); }
public EntityRepository(CustomerDbContext dbContext) { _dbContext = dbContext; _dbSet = _dbContext.Set <T>(); }
public Repository(CustomerDbContext dbContext) { _dbContext = dbContext ?? throw new ArgumentNullException(); ModelDbSets = _dbContext.Set <TModel>(); }
public async Task <IEnumerable <T> > GetAllAsync() { return(await _context.Set <T>().ToListAsync()); }
public BaseRepository(CustomerDbContext context) { this._context = context; this._dbSet = context.Set <TEntity>(); }
public RepositoryBase(CustomerDbContext context) { _context = context; _dbSet = context.Set <TEntity>(); }
public CustomerRepository(CustomerDbContext context) { _db = context; _dbSet = _db.Set <Customer>(); }
public GenericRepository(CustomerDbContext customerDbContext) { context = customerDbContext; dbSet = context.Set <TEntity>(); }