mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add unit test
This commit is contained in:
parent
331136f14d
commit
edd39b696e
@ -97,6 +97,7 @@
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UnitManyToMay1231.cs" />
|
||||
<Compile Include="UnitTest\UnitOneToOneN.cs" />
|
||||
<Compile Include="UnitTest\UCustom024.cs" />
|
||||
<Compile Include="UnitTest\UCustomNavigate01.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UnitManyToMay1231.Init();
|
||||
UnitUpdateNav2.Init();
|
||||
UnitUpdateNav.Init();
|
||||
UnitOneToOneN.Init();
|
||||
|
117
Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMay1231.cs
Normal file
117
Src/Asp.Net/SqlServerTest/UnitTest/UnitManyToMay1231.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using System;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Linq;
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
using SqlSugar;
|
||||
|
||||
namespace OrmTest
|
||||
|
||||
{
|
||||
|
||||
public class UnitManyToMay1231
|
||||
|
||||
{
|
||||
|
||||
public static void Init()
|
||||
|
||||
{
|
||||
|
||||
var db = new SqlSugarScope(new SqlSugar.ConnectionConfig()
|
||||
|
||||
{
|
||||
|
||||
ConnectionString = Config.ConnectionString,
|
||||
|
||||
DbType = DbType.SqlServer,
|
||||
|
||||
IsAutoCloseConnection = true
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
//用例代码
|
||||
|
||||
var result = db.Queryable<StudentA__1>()
|
||||
|
||||
.Where(student => student.School.Rooms.Any())
|
||||
|
||||
.ToSqlString();//用例代码
|
||||
|
||||
if (result != "SELECT [StudentId],[SchoolNo] FROM [StudentA__1] student WHERE EXISTS( ( SELECT 1 FROM [SchoolA__1] SchoolA__10 Inner JOIN [SchoolAndRoomA__1] SchoolAndRoomA__1_1 ON SchoolAndRoomA__1_1.[SchoolId]=SchoolA__10.[SchoolId] Inner JOIN [RoomA__1] RoomA__11 ON RoomA__11.[RoomId]=SchoolAndRoomA__1_1.[RoomId] WHERE student.[SchoolNo] = SchoolA__10.[SchoolNo] ) ) ")
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//建类
|
||||
|
||||
public class StudentA__1
|
||||
|
||||
{
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
||||
public int StudentId { get; set; }
|
||||
|
||||
public int SchoolNo { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(SchoolNo), nameof(SchoolA__1.SchoolNo))]
|
||||
|
||||
public SchoolA__1 School { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SchoolA__1
|
||||
|
||||
{
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
||||
public int SchoolId { get; set; }
|
||||
|
||||
public int SchoolNo { get; set; }
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
[Navigate(typeof(SchoolAndRoomA__1), nameof(SchoolAndRoomA__1.SchoolId), nameof(SchoolAndRoomA__1.RoomId))]
|
||||
|
||||
public List<RoomA__1> Rooms { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class SchoolAndRoomA__1
|
||||
|
||||
{
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
||||
public int SchoolId { get; set; }
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class RoomA__1
|
||||
|
||||
{
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
|
||||
public int RoomId { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user