ISqlSugarClient Add AsTenant

This commit is contained in:
sunkaixuna 2021-11-03 14:25:35 +08:00
parent 659ab5f179
commit 094c75ed2f
4 changed files with 20 additions and 1 deletions

View File

@ -1168,5 +1168,14 @@ namespace SqlSugar
};
}
#endregion
#region AsTenant
public ITenant AsTenant()
{
Check.Exception(true,ErrorMessage.GetThrowMessage("Child objects do not support tenant methods, var childDb= Db.GetConnection(confid) ,Db is master ", "Db子对象不支持租户方法请使用主对象,例如var childDb= Db.GetConnection(confid) Db是主对象childDb是子对象 "));
return null;
}
#endregion
}
}

View File

@ -52,7 +52,8 @@ namespace SqlSugar
void InitMappingInfo(Type type);
void InitMappingInfo<T>();
void Open();
void Close();
void Close();
ITenant AsTenant();
#endregion
#region Insertable

View File

@ -576,6 +576,11 @@ namespace SqlSugar
#endregion
#region TenantManager
public ITenant AsTenant()
{
var tenant= this as ITenant;
return tenant;
}
public SqlSguarTransaction UseTran()
{
return new SqlSguarTransaction(this);

View File

@ -65,6 +65,10 @@ namespace SqlSugar
public SugarCacheProvider DataCache => ScopedContext.DataCache;
public ITenant AsTenant()
{
return ScopedContext.AsTenant();
}
public void AddConnection(ConnectionConfig connection)
{
ScopedContext.AddConnection(connection);