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
a88ac5061b
commit
0cf095c52d
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UnitOneToOneDel.Init();
|
||||||
EntityInfoTest.Init();
|
EntityInfoTest.Init();
|
||||||
UnitOneToManyafdaa.Init();
|
UnitOneToManyafdaa.Init();
|
||||||
Unitadfafa.Init();
|
Unitadfafa.Init();
|
||||||
|
55
Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneDel.cs
Normal file
55
Src/Asp.NetCore2/SqlSeverTest/UnitTest/UnitOneToOneDel.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
internal class UnitOneToOneDel
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var Db = new SqlSugarScope(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
ConnectionString = Config.ConnectionString,
|
||||||
|
IsAutoCloseConnection = true
|
||||||
|
});
|
||||||
|
Db.CodeFirst.InitTables<School, Grade>();
|
||||||
|
Db.DbMaintenance.TruncateTable<School, Grade>();
|
||||||
|
Db.Insertable(new School()
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Name = "a"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
Db.Insertable(new Grade()
|
||||||
|
{
|
||||||
|
Name= "b",
|
||||||
|
SchoolId=1,
|
||||||
|
}).ExecuteCommand();
|
||||||
|
Db.DeleteNav<School>(s => s.Id.Equals(4))
|
||||||
|
.Include(s => s.Grades).ExecuteCommandAsync().GetAwaiter().GetResult();
|
||||||
|
Console.ReadLine();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SugarTable("unitSchooldfadsaa")]
|
||||||
|
|
||||||
|
public class School
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
[Navigate(NavigateType.OneToOne, nameof(Grade.SchoolId))]
|
||||||
|
public Grade Grades { get; set; }
|
||||||
|
}
|
||||||
|
[SugarTable("unitGradedfadsaa")]
|
||||||
|
public class Grade
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public int SchoolId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user