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
fd6a3c8362
commit
ba5a113d9b
@ -97,6 +97,11 @@
|
||||
<Compile Include="Models\OrderItem.cs" />
|
||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\Models\001\InsuranceSectionConfig.cs" />
|
||||
<Compile Include="UnitTest\Models\001\ShouJi.cs" />
|
||||
<Compile Include="UnitTest\Models\001\ShoujiSubnum.cs" />
|
||||
<Compile Include="UnitTest\Models\001\ShoujiViewDto.cs" />
|
||||
<Compile Include="UnitTest\Models\Unit23131.cs" />
|
||||
<Compile Include="UnitTest\UinitCustomConvert.cs" />
|
||||
<Compile Include="UnitTest\UInsert3.cs" />
|
||||
<Compile Include="UnitTest\UJson2.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Unit23131.Init();
|
||||
SplitTest2();
|
||||
UOneManyMany7.init();
|
||||
UinitCustomConvert.Init();
|
||||
|
@ -0,0 +1,29 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Demo
|
||||
{
|
||||
///<summary>
|
||||
///畜禽分段信息
|
||||
///</summary>
|
||||
[SugarTable("insurance_section_config")]
|
||||
public class InsuranceSectionConfig
|
||||
{
|
||||
public InsuranceSectionConfig()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:分段ID
|
||||
/// Default:
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "分段ID", IsNullable = false)]
|
||||
public int insurance_section_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:畜种细分编码
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "畜种细分编码", Length = 10, IsNullable = true)]
|
||||
public string category_code { get; set; }
|
||||
}
|
||||
}
|
43
Src/Asp.Net/SqlServerTest/UnitTest/Models/001/ShouJi.cs
Normal file
43
Src/Asp.Net/SqlServerTest/UnitTest/Models/001/ShouJi.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Demo
|
||||
{
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarTable("shouji")]
|
||||
public class ShouJi
|
||||
{
|
||||
public ShouJi()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:收集单流水号
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "收集单流水号", Length = 16)]
|
||||
public string shouji_sysno { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:收集单据号,多个逗号分隔
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "收集单据号,多个逗号分隔", Length = 200)]
|
||||
public string shouji_sn { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:收集单ID
|
||||
/// Default:newid()
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "收集单GUID")]
|
||||
public string shouji_guid { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:收集单ID
|
||||
/// Default:newid()
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "收集单GUID")]
|
||||
public string xuqin_name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Demo
|
||||
{
|
||||
///<summary>
|
||||
///
|
||||
///</summary>
|
||||
[SugarTable("shouji_subnum")]
|
||||
public class ShoujiSubnum
|
||||
{
|
||||
public ShoujiSubnum()
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// Desc:分段ID
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public int? insurance_section_id { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:收集单ID
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public string shouji_guid { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:分段数量
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? amount { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:预估理赔金额
|
||||
/// Default:
|
||||
/// Nullable:True
|
||||
/// </summary>
|
||||
public decimal? total_money { get; set; }
|
||||
/// <summary>
|
||||
/// Desc:收集分段ID
|
||||
/// Default:newid()
|
||||
/// Nullable:False
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string sub_shouji_guid { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace Demo
|
||||
{
|
||||
public class ShoujiViewDto
|
||||
{
|
||||
public string shouji_guid { get; set; }
|
||||
public string xuqin_name { get; set; }
|
||||
}
|
||||
}
|
41
Src/Asp.Net/SqlServerTest/UnitTest/Models/Unit23131.cs
Normal file
41
Src/Asp.Net/SqlServerTest/UnitTest/Models/Unit23131.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using Demo;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class Unit23131
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
|
||||
//var connStr = "server=192.168.88.190;database=SDWHH2206;uid=whh;pwd=Zowie2023";
|
||||
var connStr1 = "Server=192.168.88.180;Port=54321;UID=whh;PWD=whh@123;database=zhsy_whh;searchpath=dbo;";
|
||||
//SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = connStr, DbType = DbType.SqlServer });
|
||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = connStr1, DbType = DbType.Kdbndp });
|
||||
|
||||
var list = db.Queryable<ShouJi>().Select(s => new ShoujiViewDto
|
||||
{
|
||||
shouji_guid = s.shouji_guid.SelectAll()
|
||||
}).MergeTable().Where(w => w.xuqin_name != null)
|
||||
.Where(w => w.shouji_guid == SqlFunc.Subqueryable<ShoujiSubnum>().Where(ss => ss.amount > 0
|
||||
&& ss.insurance_section_id ==
|
||||
SqlFunc.Subqueryable<InsuranceSectionConfig>()
|
||||
.GroupBy(i => i.insurance_section_id)
|
||||
.Where(i => i.category_code == "123" && i.insurance_section_id == ss.insurance_section_id)
|
||||
.Select(i => i.insurance_section_id)
|
||||
).GroupBy(ss => ss.shouji_guid)
|
||||
.Select(ss => ss.shouji_guid)).ToSql();
|
||||
|
||||
if (!list.Key.Contains("\"INSURANCE_SECTION_CONFIG\" \"I\""))
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user