mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Add unit test
This commit is contained in:
parent
644c069976
commit
31b0a715b4
@ -97,6 +97,7 @@
|
||||
<Compile Include="UnitTest\UCustom01.cs" />
|
||||
<Compile Include="UnitTest\UCustom02.cs" />
|
||||
<Compile Include="UnitTest\UCustom03.cs" />
|
||||
<Compile Include="UnitTest\UCustom04.cs" />
|
||||
<Compile Include="UnitTest\UDelete.cs" />
|
||||
<Compile Include="UnitTest\UFastest.cs" />
|
||||
<Compile Include="UnitTest\UConfig.cs" />
|
||||
|
@ -34,6 +34,7 @@ namespace OrmTest
|
||||
UCustom01.Init();
|
||||
UCustom02.Init();
|
||||
UCustom03.Init();
|
||||
UCustom04.Init();
|
||||
SubQueryTest();
|
||||
UConfig();
|
||||
DeleteTest();
|
||||
|
38
Src/Asp.Net/SqlServerTest/UnitTest/UCustom04.cs
Normal file
38
Src/Asp.Net/SqlServerTest/UnitTest/UCustom04.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class UCustom04
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
var sql = db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
|
||||
JoinType.Left, o.Id == i.OrderId,
|
||||
JoinType.Left, o.CustomId == c.Id
|
||||
))
|
||||
.Select<ViewModel>().ToSql().Key;
|
||||
UValidate.Check(sql, @"SELECT o.[Name] AS [Name],o.[Price] AS [Price],i.[OrderId] AS [OrderItemOrderId],i.[Price] AS [OrderItemPrice],c.[Name] AS [CustomName] FROM [Order] o Left JOIN [OrderDetail] i ON ( [o].[Id] = [i].[OrderId] ) Left JOIN [Custom] c ON ( [o].[CustomId] = [c].[Id] )","unit");
|
||||
var list =
|
||||
db.Queryable<Order, OrderItem, Custom>((o, i, c) => new JoinQueryInfos(
|
||||
JoinType.Left, o.Id == i.OrderId,
|
||||
JoinType.Left, o.CustomId == c.Id
|
||||
))
|
||||
.Where((o,i,c)=>i.ItemId>0&&c.Id>0)
|
||||
.Select<ViewModel>().ToList();
|
||||
}
|
||||
public class ViewModel
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
public int OrderItemOrderId { get; set; }
|
||||
public int OrderItemPrice { get; set; }
|
||||
public string CustomName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user