Update demo

This commit is contained in:
sunkaixuan
2023-11-06 21:44:56 +08:00
parent 87337c9204
commit edd85a6381
128 changed files with 1717 additions and 77 deletions

View File

@@ -0,0 +1,56 @@
using SqlSeverTest.UserTestCases;
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(1))
.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(Id), 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; }
}
}