pgsql 同时操作多个schema 返回
SqlSugar
沟通中
4
464
ivesbao 发布于2026/2/4
悬赏:0 飞吻
无实体增删改的时候能不能动态切换schema,或者在insertable这样的函数或者as表名的时候指定schema
热忱回答(4)
-
fate sta VIP0
2026/2/4vardb =newSqlSugarClient(newList<ConnectionConfig>(){newConnectionConfig(){ConfigId="A",DbType=DbType.PostgreSQL,ConnectionString="..",IsAutoCloseConnection=true},newConnectionConfig(){ConfigId="B",DbType=DbType.PostgreSQL,DbLinkName="public",//重点ConnectionString=".....;searchpath=public"//重点,IsAutoCloseConnection=true},});varx3 = db.QueryableWithAttr<OptRole>().LeftJoin<Role>((x1,y1)=>x1.roleId==y1.id)//Left Join时会加上public..ToList();searchpath可以设置schema。
结合多租户实现多个schema操作
//获取子DbvarchildA=db.GetConnection("A");varchildB=db.GetConnection("B");0 回复 -
沐沐 VIP0
2026/4/9这个方法不管用,我现在只有在表名上加模式名才管用[SugarTable("模式名.表名")],连接字符串也不用配置searchpat
0 回复 -
fate sta VIP0
2026/4/9不是表名上加模式名.是字符串加上。
0 回复 -
fate sta VIP0
2026/4/9表名就是表名。只配置searchpath
0 回复