mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-24 08:33:16 +08:00
Optimize unit test cases
This commit is contained in:
@@ -146,15 +146,13 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder>()
|
||||
.GroupBy(o => o.CustomerId)
|
||||
.Having(o => SqlFunc.AggregateCount(o.OrderId) > 1)
|
||||
.Select(o => new
|
||||
.Select<object>(o => new
|
||||
{
|
||||
CustomerId = o.CustomerId,
|
||||
OrderCount = SqlFunc.AggregateCount(o.OrderId),
|
||||
TotalAmount = SqlFunc.AggregateSum(o.TotalAmount),
|
||||
AvgAmount = SqlFunc.AggregateAvg(o.TotalAmount)
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -185,13 +183,13 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
{
|
||||
var query1 = _sqlSugarDb.Queryable<BenchmarkCustomer>()
|
||||
.Where(c => c.City == "CityA")
|
||||
.Select(c => new { c.CustomerId, c.CustomerName });
|
||||
.Select<object>(c => new { c.CustomerId, c.CustomerName });
|
||||
|
||||
var query2 = _sqlSugarDb.Queryable<BenchmarkCustomer>()
|
||||
.Where(c => c.City == "CityB")
|
||||
.Select(c => new { c.CustomerId, c.CustomerName });
|
||||
.Select<object>(c => new { c.CustomerId, c.CustomerName });
|
||||
|
||||
return _sqlSugarDb.UnionAll(query1, query2).ToList().Cast<object>().ToList();
|
||||
return _sqlSugarDb.UnionAll(query1, query2).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -286,7 +284,7 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
[Benchmark]
|
||||
public object SqlSugar_AggregateFunctions()
|
||||
{
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder>().Select(it => new
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder>().Select<object>(it => new
|
||||
{
|
||||
Count = SqlFunc.AggregateCount(it.OrderId),
|
||||
Sum = SqlFunc.AggregateSum(it.TotalAmount),
|
||||
|
||||
@@ -141,16 +141,14 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
{
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder, BenchmarkCustomer>(
|
||||
(o, c) => o.CustomerId == c.CustomerId)
|
||||
.Select((o, c) => new
|
||||
.Select<object>((o, c) => new
|
||||
{
|
||||
o.OrderId,
|
||||
o.OrderNumber,
|
||||
o.TotalAmount,
|
||||
CustomerName = c.CustomerName,
|
||||
CustomerEmail = c.Email
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -178,14 +176,12 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
{
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder>()
|
||||
.LeftJoin<BenchmarkCustomer>((o, c) => o.CustomerId == c.CustomerId)
|
||||
.Select((o, c) => new
|
||||
.Select<object>((o, c) => new
|
||||
{
|
||||
o.OrderId,
|
||||
o.OrderNumber,
|
||||
CustomerName = c.CustomerName
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -216,7 +212,7 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
JoinType.Left, o.OrderId == oi.OrderId,
|
||||
JoinType.Left, oi.ProductId == p.ProductId
|
||||
))
|
||||
.Select((o, c, oi, p) => new
|
||||
.Select<object>((o, c, oi, p) => new
|
||||
{
|
||||
o.OrderId,
|
||||
o.OrderNumber,
|
||||
@@ -224,9 +220,7 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
ProductName = p.ProductName,
|
||||
oi.Quantity,
|
||||
oi.TotalPrice
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -257,14 +251,12 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder, BenchmarkCustomer>(
|
||||
(o, c) => o.CustomerId == c.CustomerId)
|
||||
.Where((o, c) => o.Status == "Completed" && c.IsActive == true)
|
||||
.Select((o, c) => new
|
||||
.Select<object>((o, c) => new
|
||||
{
|
||||
o.OrderId,
|
||||
o.OrderNumber,
|
||||
CustomerName = c.CustomerName
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
@@ -293,15 +285,13 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder, BenchmarkCustomer>(
|
||||
(o, c) => o.CustomerId == c.CustomerId)
|
||||
.GroupBy((o, c) => c.CustomerId)
|
||||
.Select((o, c) => new
|
||||
.Select<object>((o, c) => new
|
||||
{
|
||||
CustomerId = c.CustomerId,
|
||||
CustomerName = c.CustomerName,
|
||||
OrderCount = SqlFunc.AggregateCount(o.OrderId),
|
||||
TotalAmount = SqlFunc.AggregateSum(o.TotalAmount)
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -267,14 +267,12 @@ namespace PerformanceBenchmarks.Benchmarks
|
||||
public List<object> SqlSugar_SelectColumns()
|
||||
{
|
||||
return _sqlSugarDb.Queryable<BenchmarkOrder>()
|
||||
.Select(o => new
|
||||
.Select<object>(o => new
|
||||
{
|
||||
o.OrderId,
|
||||
o.OrderNumber,
|
||||
o.TotalAmount
|
||||
})
|
||||
.ToList()
|
||||
.Cast<object>()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user