/// <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); }
public BaseRepository(SqlDbContext context) { this.context = context; dbSet = context.Set <T>(); }