mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 优化 FreeSql.DbContext 构造方法,方便注入使用;
This commit is contained in:
@ -54,13 +54,19 @@ namespace FreeSql
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected DbContext()
|
||||
protected DbContext() : this(null, null) { }
|
||||
protected DbContext(IFreeSql fsql, DbContextOptions options)
|
||||
{
|
||||
var builder = new DbContextOptionsBuilder();
|
||||
OnConfiguring(builder);
|
||||
_ormPriv = builder._fsql;
|
||||
_optionsPriv = builder._options;
|
||||
_ormPriv = fsql;
|
||||
_optionsPriv = options;
|
||||
|
||||
if (_ormPriv == null)
|
||||
{
|
||||
var builder = new DbContextOptionsBuilder();
|
||||
OnConfiguring(builder);
|
||||
_ormPriv = builder._fsql;
|
||||
_optionsPriv = builder._options;
|
||||
}
|
||||
if (_ormPriv != null) InitPropSets();
|
||||
}
|
||||
protected virtual void OnConfiguring(DbContextOptionsBuilder builder) { }
|
||||
|
Reference in New Issue
Block a user