} //初始化一个数据库访问对象 public BaseController() { if (Db == null) {//如果不存在一个数据访问对象,则实例一个出来 Db = DbFactory.GetCurrentDbContext(); } }
public UnitOfWork() { _context = DbFactory.GetCurrentDbContext(); }
public BaseReposiory() { SiyoukuContext = DbFactory.GetCurrentDbContext(); }
//构造器注入 public WenqingController(SiyoukuContext siyoukuContext) { _siyoukuContext = siyoukuContext; }
public BaseReposiory(SiyoukuContext dbContext) { SiyoukuContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); }