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
d94fb365ad
commit
f40b96c6cb
@ -121,6 +121,7 @@
|
||||
<Compile Include="UnitTest\UQueryable.cs" />
|
||||
<Compile Include="UnitTest\UQueryableAsync.cs" />
|
||||
<Compile Include="UnitTest\USaveable.cs" />
|
||||
<Compile Include="UnitTest\USelectDTO.cs" />
|
||||
<Compile Include="UnitTest\UThread.cs" />
|
||||
<Compile Include="UnitTest\UThread2.cs" />
|
||||
<Compile Include="UnitTest\UThread3.cs" />
|
||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
USelectDTO.Init();
|
||||
UnitNavOneToManyDTO.Init();
|
||||
Unitadfaafsd.Init();
|
||||
UFilter2.Init();
|
||||
|
129
Src/Asp.Net/SqliteTest/UnitTest/USelectDTO.cs
Normal file
129
Src/Asp.Net/SqliteTest/UnitTest/USelectDTO.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
internal class USelectDTO
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
db.CodeFirst.InitTables<ProductStockFlow, ProductStock>();
|
||||
|
||||
//5.1.4.86 不报错
|
||||
//5.1.4.94 报错
|
||||
|
||||
var flowQuery = db.Queryable<ProductStockFlow>()
|
||||
.GroupBy(s => new { s.ProductId })
|
||||
.Select(s => new
|
||||
{
|
||||
s.ProductId,
|
||||
LastOutTime = SqlFunc.AggregateMax(s.CreateTime)
|
||||
});
|
||||
|
||||
var data = db.Queryable<ProductStock>()
|
||||
.LeftJoin(flowQuery, (s, f) => s.ProductId == f.ProductId)
|
||||
.Where(s => s.StockQty > 0)
|
||||
.Select((s, f) => new ProductStockMonitorDto() { }, true)
|
||||
.ToList();
|
||||
|
||||
var data2 = db.Queryable<ProductStock>()
|
||||
.LeftJoin(flowQuery, (s, f) => s.ProductId == f.ProductId)
|
||||
.Where(s => s.StockQty > 0)
|
||||
.Select<ProductStockMonitorDto>()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
public class ProductStockFlow
|
||||
{
|
||||
[SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false)]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品货号
|
||||
/// </summary>
|
||||
public string ProductCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
public string ProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发生数量
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 18, DecimalDigits = 4)]
|
||||
public decimal SettleQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 发生类型
|
||||
/// </summary>
|
||||
public string SettleType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public string Remark { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
|
||||
public class ProductStock
|
||||
{
|
||||
[SugarColumn(IsNullable = false, IsPrimaryKey = true, IsIdentity = false)]
|
||||
public long Id { get; set; }
|
||||
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品货号
|
||||
/// </summary>
|
||||
public string ProductCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
public string ProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存数量
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 18, DecimalDigits = 4)]
|
||||
public decimal StockQty { get; set; }
|
||||
}
|
||||
|
||||
public class ProductStockMonitorDto
|
||||
{
|
||||
public long ProductId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品货号
|
||||
/// </summary>
|
||||
public string ProductCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 产品名称
|
||||
/// </summary>
|
||||
public string ProductName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 库存数量
|
||||
/// </summary>
|
||||
public decimal StockQty { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后出库时间
|
||||
/// </summary>
|
||||
public DateTime? LastOutTime { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user