mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-24 13:03:43 +08:00
Update demo
This commit is contained in:
@@ -21,18 +21,19 @@ namespace OrmTest
|
||||
{
|
||||
public void Test()
|
||||
{
|
||||
base.AsTenant().BeginTran();
|
||||
base.db.BeginTran();
|
||||
|
||||
base.GetList(); //调用内部仓储方法
|
||||
base.ChangeRepository<Repository<C2Table>>().GetList();//调用外部仓储
|
||||
|
||||
base.AsTenant().CommitTran();
|
||||
base.db.CommitTran();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class Repository<T> : SimpleClient<T> where T : class, new()
|
||||
{
|
||||
public SqlSugarClient db;
|
||||
public Repository(ISqlSugarClient context = null) : base(context)//注意这里要有默认值等于null
|
||||
{
|
||||
if (context == null)
|
||||
@@ -53,10 +54,10 @@ namespace OrmTest
|
||||
ConnectionString = Config.ConnectionString2
|
||||
}
|
||||
});
|
||||
base.Context = db;
|
||||
|
||||
var configId = typeof(T).GetCustomAttribute<TenantAttribute>().configId;
|
||||
db.ChangeDatabase(configId);
|
||||
|
||||
Context = db.GetConnection(configId);
|
||||
this.db = db;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user