///
private RentHouseContext db;
//在BaseService中不实例化上下文,将实例化的工作交给实现方
public BaseService(RentHouseContext db)
{
this.db = db;
}
/// <summary>
/// 添加实体
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
//编写用户相关的基础操作
public long Add(T entity)
{
db.Entry<T>(entity).State = EntityState.Added;
db.SaveChanges();
return entity.Id;
}