Update demo

This commit is contained in:
sunkaixuna
2021-04-25 21:37:50 +08:00
parent 445d7e5dca
commit da6012774f

View File

@@ -21,13 +21,13 @@ namespace OrmTest
{
public void Test()
{
base.GetList();
base.ChangeRepository<C2Service>().GetList();
}
}
public class C2Service : Repository<C2Table>
{
base.AsTenant().BeginTran();
base.GetList(); //调用内部仓储方法
base.ChangeRepository<Repository<C2Table>>().GetList();//调用外部仓储
base.AsTenant().CommitTran();
}
}
@@ -40,7 +40,7 @@ namespace OrmTest
var db = new SqlSugarClient(new List<ConnectionConfig> {
new ConnectionConfig()
{
ConfigId=1,
ConfigId="1",
DbType = SqlSugar.DbType.SqlServer,
IsAutoCloseConnection = true,
ConnectionString = Config.ConnectionString
@@ -53,13 +53,10 @@ namespace OrmTest
ConnectionString = Config.ConnectionString2
}
});
base.Context = db;
var configId = typeof(T).GetCustomAttribute<TenantAttribute>().configId;
base.Context = db.GetConnection(configId);
base.Context.CodeFirst.InitTables<T>();
db.Aop.OnLogExecuting = (s, p) =>
{
Console.WriteLine(s);
};
db.ChangeDatabase(configId);
}
}