예제 #1
0
        public async Task <T> AddAsync(T entity, CancellationToken cancellationToken = default)
        {
            await _dbContext.Set <T>().AddAsync(entity);

            await _dbContext.SaveChangesAsync(cancellationToken);

            return(entity);
        }
예제 #2
0
        public async Task <T> AddAsync(T entity)
        {
            await _dbContext.Set <T>().AddAsync(entity);

            await _dbContext.SaveChangesAsync();

            return(entity);
        }
예제 #3
0
 public async Task <T> GetByIdAsync(int id)
 {
     return(await _eFContext.Set <T>().FindAsync(id));
 }
예제 #4
0
 public virtual T GetById(int id)
 {
     return(_dbContext.Set <T>().Find(id));
 }
예제 #5
0
 public T GetById(int id)
 {
     return(_dbContext.Set <T>().SingleOrDefault(e => e.Id == id));
 }