public async Task <T> AddAsync(T entity)
        {
            _dbContext.Set <T>().Add(entity);
            await _dbContext.SaveChangesAsync();

            return(entity);
        }
示例#2
0
 public async Task <IReadOnlyList <T> > GetAllAsync()
 {
     return(await _dbContext.Set <T>().ToListAsync());
 }
示例#3
0
 public GenericRepo(WebAppContext context)
 {
     this.context = context;
     this.dbSet   = context.Set <TEntity>();
 }
示例#4
0
 protected RepositoryBase(WebAppContext dbContext)
 {
     this.dbContext = dbContext;
     dbSet          = dbContext.Set <T>();
 }
 public GenericRepository(WebAppContext context)
 {
     this.context = context;
     dbSet        = context.Set <TEntity>();
 }