Closed goodnull closed 6 months ago
我看到文档 多租户、多数据库 都是通过ConnectionConfig配置,使用时,通过在实体标注特性[TenantAttribute("0")]//对应ConfigId, 这样写有些麻烦
ConnectionConfig
[TenantAttribute("0")]//对应ConfigId
连接字符串为: server=192.168.1.161;uid=sa;pwd=sa123;database=Stu 我要查询Stu里的stulist表
server=192.168.1.161;uid=sa;pwd=sa123;database=Stu
select top 100 * from Stu.dbo.Stulist Db.Queryable<Stulist>().ToList()
如果我要查这台数据库服务器的Techer数据库的techs表 select top 100 * from Techer.dbo.techs
select top 100 * from Techer.dbo.techs
sql语句中是不用更换连接字符串可以直接操作另一个库的 所以SqlSugar有没有类似的,比如 Db.Queryable<techs>().AsDB("Techer").ToList() 这样就切换了数据库
Db.Queryable<techs>().AsDB("Techer").ToList()
Db.Queryable<techs>().As("Techer.dbo.techs").ToList()
这样就可
或者
db.GetConnection("configId").Queryable<techs>().ToList()
先关闭,还有疑问发新的issue
我看到文档 多租户、多数据库 都是通过
ConnectionConfig
配置,使用时,通过在实体标注特性[TenantAttribute("0")]//对应ConfigId
, 这样写有些麻烦连接字符串为:
server=192.168.1.161;uid=sa;pwd=sa123;database=Stu
我要查询Stu里的stulist表如果我要查这台数据库服务器的Techer数据库的techs表
select top 100 * from Techer.dbo.techs
sql语句中是不用更换连接字符串可以直接操作另一个库的 所以SqlSugar有没有类似的,比如
Db.Queryable<techs>().AsDB("Techer").ToList()
这样就切换了数据库