diff --git a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj index 8721e0851..a96a30aa0 100644 --- a/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj +++ b/Src/Asp.Net/PgSqlTest/PgSqlTest.csproj @@ -103,6 +103,7 @@ + diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/CrossDatabase02.cs b/Src/Asp.Net/PgSqlTest/UnitTest/CrossDatabase02.cs new file mode 100644 index 000000000..9bcc8ebf7 --- /dev/null +++ b/Src/Asp.Net/PgSqlTest/UnitTest/CrossDatabase02.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SqlSugar; + + +namespace OrmTest +{ + public class CrossDatabase02 + { + public static void Init() + { + + var db = new SqlSugarClient(new List() + { + new ConnectionConfig(){ConfigId="A",DbType=DbType.PostgreSQL,ConnectionString=Config.ConnectionString,IsAutoCloseConnection=true}, + new ConnectionConfig(){ConfigId="B",DbType=DbType.PostgreSQL,DbLinkName="public",ConnectionString=Config.ConnectionString,IsAutoCloseConnection=true }, + + }); + + db.Aop.OnLogExecuting = (x, y) => Console.WriteLine(UtilMethods.GetNativeSql(x,y)); + + db.GetConnection("A").CodeFirst.InitTables(); + db.GetConnection("B").CodeFirst.InitTables(); + + db.GetConnection("A").DbMaintenance.TruncateTable(); + db.GetConnection("B").DbMaintenance.TruncateTable(); + + + var x3 = db.QueryableWithAttr() + .LeftJoin((x1, y1) => x1.roleId == y1.id).ToList(); + + } + + + /// + /// 描述: + /// 作者:synjones + /// 时间:2022-04-20 21:30:28 + /// + [SugarTable("unit_role18")] + [Tenant("B")] + public partial class Role + { + /// + /// 角色 + /// + [SugarColumn(IsPrimaryKey = true )] + public int id { get; set; } + + /// + /// 角色名称 + /// + public string name { get; set; } + + } + + + /// + /// 描述: + /// 作者:synjones + /// 时间:2022-04-21 14:35:09 + /// + [SugarTable("unit_operator_role8")] + [Tenant("A")] + public partial class OptRole + { + /// + /// + /// + [SugarColumn(IsPrimaryKey = true)] + public int id { get; set; } + + /// + /// + /// + public int operId { get; set; } + public int roleId { get; set; } + + } + } +} diff --git a/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs b/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs index 7feefe15b..e4dc0821e 100644 --- a/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs +++ b/Src/Asp.Net/PgSqlTest/UnitTest/Main.cs @@ -31,6 +31,7 @@ namespace OrmTest } public static void Init() { + CrossDatabase02.Init(); UinitCustomConvert.Init(); ULock.Init(); UInsert3.Init();