Пример #1
0
 /// <summary>
 /// 保存实体entity到数据库
 /// </summary>
 /// <param name="entity">entity实体</param>
 /// <returns>返回保存到数据库实体的Id</returns>
 public int Save(T entity)
 {
     context.Set <T>().Add(entity);
     context.SaveChanges();
     return(entity.Id);
 }
Пример #2
0
 public BaseRepository(SqlDbContext context)
 {
     this.context = context;
     dbSet        = context.Set <T>();
 }