/// <summary> /// create new record in entity /// </summary> /// <param name="entity"></param> /// <returns> /// return id. /// </returns> public async Task <int> Create(T entity) { await _dbContext.Set <T>().AddAsync(entity); int id = await _dbContext.SaveChangesAsync(); return(id); }
public IQueryable <TEntity> Select() { return(Context.Set <TEntity>().AsQueryable()); }
public ExpenditureModel FindById(int id) { return(_context.Set <ExpenditureModel>().AsNoTracking().FirstOrDefault(a => a.id == id)); }
/// <summary> /// 新增一筆資料到資料庫。 /// </summary> /// <param name="entity">要新增到資料的庫的Entity</param> public void Create(TEntity entity) { Context.Set <TEntity>().Add(entity); }