mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Add unit test
This commit is contained in:
parent
8d62e1419d
commit
22d5a881a0
@ -95,6 +95,7 @@
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UCustom021.cs" />
|
||||
<Compile Include="UnitTest\UByteArray.cs" />
|
||||
<Compile Include="UnitTest\UIncludesBigData.cs" />
|
||||
<Compile Include="UnitTest\UCustom020.cs" />
|
||||
|
@ -32,6 +32,7 @@ namespace OrmTest
|
||||
public static void Init()
|
||||
{
|
||||
UByteArray.Init();
|
||||
UCustom021.Inti();
|
||||
UCustom020.Init();
|
||||
UCustom019.Init();
|
||||
UnitManyToMany.Init();
|
||||
|
50
Src/Asp.Net/SqlServerTest/UnitTest/UCustom021.cs
Normal file
50
Src/Asp.Net/SqlServerTest/UnitTest/UCustom021.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
namespace OrmTest
|
||||
{
|
||||
public class UCustom021
|
||||
{
|
||||
public static void Inti() {
|
||||
var db = NewUnitTest.Db;
|
||||
db.CodeFirst.SetStringDefaultLength(20).InitTables<UnitStudent111>();
|
||||
db.CodeFirst.SetStringDefaultLength(20).InitTables<UnitExam>();
|
||||
|
||||
var id = db.Insertable(new UnitStudent111() { Name = "小a" }).ExecuteReturnIdentity();
|
||||
db.Insertable(new UnitExam
|
||||
{
|
||||
StudentId = id,
|
||||
Number = 1,
|
||||
Time = DateTime.Now
|
||||
}).ExecuteCommand();
|
||||
|
||||
var result2 = db.Queryable<UnitStudent111>()
|
||||
.Includes(e => e.Exams.Where(s => s.Id >e.Id).ToList()).ToList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class UnitStudent111
|
||||
{
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[Navigate(NavigateType.OneToMany, nameof(UnitExam.StudentId))]//BookA表中的studenId
|
||||
public List<UnitExam> Exams { get; set; }
|
||||
|
||||
}
|
||||
public class UnitExam
|
||||
{
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public int Id { get; set; }
|
||||
public int StudentId { get; set; }
|
||||
public int Number { get; set; }
|
||||
public DateTime Time { get; set; }
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user