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
65ddacd313
commit
f2afb387bc
@ -106,6 +106,7 @@
|
|||||||
<Compile Include="UnitTest\UinitCustomConvert.cs" />
|
<Compile Include="UnitTest\UinitCustomConvert.cs" />
|
||||||
<Compile Include="UnitTest\UInsert3.cs" />
|
<Compile Include="UnitTest\UInsert3.cs" />
|
||||||
<Compile Include="UnitTest\UJson2.cs" />
|
<Compile Include="UnitTest\UJson2.cs" />
|
||||||
|
<Compile Include="UnitTest\Unitadf1131.cs" />
|
||||||
<Compile Include="UnitTest\Unitadfa1231.cs" />
|
<Compile Include="UnitTest\Unitadfa1231.cs" />
|
||||||
<Compile Include="UnitTest\UnitFilterasdfas.cs" />
|
<Compile Include="UnitTest\UnitFilterasdfas.cs" />
|
||||||
<Compile Include="UnitTest\UnitManyToMany4.cs" />
|
<Compile Include="UnitTest\UnitManyToMany4.cs" />
|
||||||
|
69
Src/Asp.Net/SqlServerTest/UnitTest/Unitadf1131.cs
Normal file
69
Src/Asp.Net/SqlServerTest/UnitTest/Unitadf1131.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Data.SqlTypes;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OrmTest.UnitTest
|
||||||
|
{
|
||||||
|
internal class Unitadf1131
|
||||||
|
{
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = NewUnitTest.Db;
|
||||||
|
db.CodeFirst.InitTables<PmtSetting>();
|
||||||
|
db.CodeFirst.InitTables<BankTemplate>();
|
||||||
|
db.DbMaintenance.TruncateTable<PmtSetting, BankTemplate>();
|
||||||
|
db.Insertable(new PmtSetting() {
|
||||||
|
TemplateName= TemplateName.T1_HSBC_CNY,
|
||||||
|
PaymentApproach="a"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
db.Insertable(new BankTemplate()
|
||||||
|
{
|
||||||
|
TemplateName = TemplateName.T1_HSBC_CNY,
|
||||||
|
TemplateData=new byte[] { 1},
|
||||||
|
TemplateFileName="a"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
var list=db.Queryable<PmtSetting>().Includes(x => x.Template).ToList();
|
||||||
|
}
|
||||||
|
// 主表
|
||||||
|
public class PmtSetting
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDataType = "int", ColumnName = "TemplateName", IsNullable = true)]
|
||||||
|
public TemplateName TemplateName { get; set; }
|
||||||
|
|
||||||
|
public string PaymentApproach { get; set; }
|
||||||
|
[Navigate(NavigateType.OneToOne, nameof(TemplateName), nameof(BankTemplate.TemplateName))]
|
||||||
|
public BankTemplate Template { get; set; } //子表对象
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 子表
|
||||||
|
public class BankTemplate
|
||||||
|
{
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDataType = "int", IsNullable = false, IsPrimaryKey = true)]
|
||||||
|
public TemplateName TemplateName { get; set; }
|
||||||
|
public string TemplateFileName { get; set; }
|
||||||
|
public byte[] TemplateData { get; set; }
|
||||||
|
}
|
||||||
|
// 枚举
|
||||||
|
public enum TemplateName
|
||||||
|
{
|
||||||
|
T1_HSBC_CNY = 1,
|
||||||
|
T2_HSBC_NONCNY = 2,
|
||||||
|
T3_BOC_PRIVATE = 3,
|
||||||
|
T4_BOC_USD = 4,
|
||||||
|
T5_BOC_EUR = 5,
|
||||||
|
T6_BOC_OTHERS = 6,
|
||||||
|
T7_BOC_UNIT = 7
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user