mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add unit test
This commit is contained in:
parent
57dd897dab
commit
a8bf2590a5
@ -77,6 +77,7 @@
|
||||
<Compile Include="Models\TestTree.cs" />
|
||||
<Compile Include="Models\Tree.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UnitNavInsertIssue.cs" />
|
||||
<Compile Include="UnitTest\UnitInsertNavN.cs" />
|
||||
<Compile Include="UnitTest\Main.cs" />
|
||||
<Compile Include="UnitTest\Models\Export.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UnitNavInsertIssue.Init();
|
||||
UnitInsertNavN.Init();
|
||||
UNavTest.Init();
|
||||
UnitTestReturnPkList.Init();
|
||||
|
62
Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertIssue.cs
Normal file
62
Src/Asp.Net/SqliteTest/UnitTest/UnitNavInsertIssue.cs
Normal file
@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SqlSugar;
|
||||
namespace OrmTest
|
||||
{
|
||||
|
||||
public class UnitNavInsertIssue
|
||||
{
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
ConnectionConfig cfg = new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.MySql,
|
||||
ConnectionString = "随便填一个本地的吧"
|
||||
};
|
||||
var sqlSugarScope = NewUnitTest.Db;
|
||||
sqlSugarScope.DbMaintenance.CreateDatabase();
|
||||
sqlSugarScope.CodeFirst.InitTables(typeof(Mail), typeof(MailAttachment));
|
||||
Mail mail = new Mail()
|
||||
{
|
||||
TraceId = "abcd",
|
||||
Subject = "subject",
|
||||
Content = "content"
|
||||
};
|
||||
sqlSugarScope
|
||||
.InsertNav(mail)
|
||||
.Include(p => p.Attachments)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
[SugarTable(nameof(Mail))]
|
||||
public class Mail
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
[SugarColumn(IsNullable = false, Length = 20)]
|
||||
public string TraceId { get; set; }
|
||||
[SugarColumn(IsNullable = false, Length = 500)]
|
||||
public string Subject { get; set; }
|
||||
[SugarColumn(IsNullable = false, Length = 2000)]
|
||||
public string Content { get; set; }
|
||||
[Navigate(NavigateType.OneToMany, nameof(MailAttachment.MailTraceId), nameof(TraceId))]
|
||||
public List<MailAttachment> Attachments { get; set; }
|
||||
}
|
||||
|
||||
[SugarTable(nameof(MailAttachment))]
|
||||
public class MailAttachment
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
[SugarColumn(IsNullable = false, Length = 20)]
|
||||
public string MailTraceId { get; set; }
|
||||
[SugarColumn(IsNullable = false, Length = 100)]
|
||||
public string FileName { get; set; }
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user