Example #1
0
        /// <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);
        }
Example #2
0
 public IQueryable <TEntity> Select()
 {
     return(Context.Set <TEntity>().AsQueryable());
 }
Example #3
0
 public ExpenditureModel FindById(int id)
 {
     return(_context.Set <ExpenditureModel>().AsNoTracking().FirstOrDefault(a => a.id == id));
 }
Example #4
0
 /// <summary>
 /// 新增一筆資料到資料庫。
 /// </summary>
 /// <param name="entity">要新增到資料的庫的Entity</param>
 public void Create(TEntity entity)
 {
     Context.Set <TEntity>().Add(entity);
 }