mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Add unit test
This commit is contained in:
parent
163dd64dd0
commit
c99a611b6e
@ -103,6 +103,7 @@
|
|||||||
<Compile Include="Models\Tree.cs" />
|
<Compile Include="Models\Tree.cs" />
|
||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
<Compile Include="Config.cs" />
|
<Compile Include="Config.cs" />
|
||||||
|
<Compile Include="UnitTest\CrossDatabase02.cs" />
|
||||||
<Compile Include="UnitTest\UinitCustomConvert.cs" />
|
<Compile Include="UnitTest\UinitCustomConvert.cs" />
|
||||||
<Compile Include="UnitTest\UInsert3.cs" />
|
<Compile Include="UnitTest\UInsert3.cs" />
|
||||||
<Compile Include="UnitTest\ULock.cs" />
|
<Compile Include="UnitTest\ULock.cs" />
|
||||||
|
83
Src/Asp.Net/PgSqlTest/UnitTest/CrossDatabase02.cs
Normal file
83
Src/Asp.Net/PgSqlTest/UnitTest/CrossDatabase02.cs
Normal file
@ -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<ConnectionConfig>()
|
||||||
|
{
|
||||||
|
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<OptRole>();
|
||||||
|
db.GetConnection("B").CodeFirst.InitTables<Role>();
|
||||||
|
|
||||||
|
db.GetConnection("A").DbMaintenance.TruncateTable<OptRole>();
|
||||||
|
db.GetConnection("B").DbMaintenance.TruncateTable<Role>();
|
||||||
|
|
||||||
|
|
||||||
|
var x3 = db.QueryableWithAttr<OptRole>()
|
||||||
|
.LeftJoin<Role>((x1, y1) => x1.roleId == y1.id).ToList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述:
|
||||||
|
/// 作者:synjones
|
||||||
|
/// 时间:2022-04-20 21:30:28
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("unit_role18")]
|
||||||
|
[Tenant("B")]
|
||||||
|
public partial class Role
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 角色
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true )]
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 角色名称
|
||||||
|
/// </summary>
|
||||||
|
public string name { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述:
|
||||||
|
/// 作者:synjones
|
||||||
|
/// 时间:2022-04-21 14:35:09
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable("unit_operator_role8")]
|
||||||
|
[Tenant("A")]
|
||||||
|
public partial class OptRole
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsPrimaryKey = true)]
|
||||||
|
public int id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public int operId { get; set; }
|
||||||
|
public int roleId { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
CrossDatabase02.Init();
|
||||||
UinitCustomConvert.Init();
|
UinitCustomConvert.Init();
|
||||||
ULock.Init();
|
ULock.Init();
|
||||||
UInsert3.Init();
|
UInsert3.Init();
|
||||||
|
Loading…
Reference in New Issue
Block a user