Skip to content

Commit

Permalink
x.6.0.27
Browse files Browse the repository at this point in the history
  • Loading branch information
xuejmnet committed Aug 9, 2022
1 parent b0f1108 commit 34c3844
Show file tree
Hide file tree
Showing 10 changed files with 731 additions and 267 deletions.
8 changes: 4 additions & 4 deletions nuget-publish.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
:start
::定义版本
set EFCORE2=2.6.0.26
set EFCORE3=3.6.0.26
set EFCORE5=5.6.0.26
set EFCORE6=6.6.0.26
set EFCORE2=2.6.0.27
set EFCORE3=3.6.0.27
set EFCORE5=5.6.0.27
set EFCORE6=6.6.0.27

::删除所有bin与obj下的文件
@echo off
Expand Down
226 changes: 145 additions & 81 deletions test/ShardingCore.Test/ShardingTest.cs

Large diffs are not rendered by default.

109 changes: 83 additions & 26 deletions test/ShardingCore.Test/ShardingTestSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,31 +1454,88 @@ public void QueryInner_Test()
var sysUserModInts = _virtualDbContext.Set<SysUserModInt>().Where(o => sysUserMods.Select(i => i.Age).Any(i => i == o.Age)).ToList();
Assert.Equal(1000, sysUserModInts.Count);
}
// [Fact]
// public void Group_API_Test()
// {
// var ids = new[] {"200", "300"};
// var dateOfMonths = new[] {202111, 202110};
// var group = _virtualDbContext.Set<SysUserSalary>()
// .Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
// .ShardingGroupBy(g => new {UId = g.UserId}, g => new
// {
//
// GroupUserId = g.Key.UId,
// Count = g.Count(),
// TotalSalary = g.Sum(o => o.Salary),
// AvgSalary = g.Average(o => o.Salary),
// AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
// MinSalary = g.Min(o => o.Salary),
// MaxSalary = g.Max(o => o.Salary)
// });
// Assert.Equal(2, group.Count);
// Assert.Equal(2, group[0].Count);
// Assert.Equal(2260000, group[0].TotalSalary);
// Assert.Equal(1130000, group[0].AvgSalary);
// Assert.Equal(11300, group[0].AvgSalaryDecimal);
// Assert.Equal(1120000, group[0].MinSalary);
// Assert.Equal(1140000, group[0].MaxSalary);
// }
[Fact]
public void Group_API_Test()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public void Group_API_Test1()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderBy(o => o.TotalSalary).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("200", group[0].GroupUserId);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public void Group_API_Test2()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderByDescending(o => o.TotalSalary).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("300", group[0].GroupUserId);
Assert.Equal(2690000, group[0].TotalSalary);
Assert.Equal(1345000, group[0].AvgSalary);
Assert.Equal(13450, group[0].AvgSalaryDecimal);
Assert.Equal(1330000, group[0].MinSalary);
Assert.Equal(1360000, group[0].MaxSalary);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace ShardingCore.Test.Shardings
public class SysUserSalaryVirtualTableRoute:AbstractShardingOperatorVirtualTableRoute<SysUserSalary,int>
{
//public override bool? EnableRouteParseCompileCache => true;
protected override bool EnableHintRoute => true;

public override string ShardingKeyToTail(object shardingKey)
{
Expand Down
109 changes: 83 additions & 26 deletions test/ShardingCore.Test2x/ShardingTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1681,31 +1681,88 @@ public async Task QueryInner_Test()
var sysUserModInts = await _virtualDbContext.Set<SysUserModInt>().Where(o=>sysUserMods.Select(i=>i.Age).Any(i=>i==o.Age)).ToListAsync();
Assert.Equal(1000, sysUserModInts.Count);
}
// [Fact]
// public async Task Group_API_Test()
// {
// var ids = new[] {"200", "300"};
// var dateOfMonths = new[] {202111, 202110};
// var group = await _virtualDbContext.Set<SysUserSalary>()
// .Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
// .ShardingGroupByAsync(g => new {UId = g.UserId}, g => new
// {
//
// GroupUserId = g.Key.UId,
// Count = g.Count(),
// TotalSalary = g.Sum(o => o.Salary),
// AvgSalary = g.Average(o => o.Salary),
// AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
// MinSalary = g.Min(o => o.Salary),
// MaxSalary = g.Max(o => o.Salary)
// });
// Assert.Equal(2, group.Count);
// Assert.Equal(2, group[0].Count);
// Assert.Equal(2260000, group[0].TotalSalary);
// Assert.Equal(1130000, group[0].AvgSalary);
// Assert.Equal(11300, group[0].AvgSalaryDecimal);
// Assert.Equal(1120000, group[0].MinSalary);
// Assert.Equal(1140000, group[0].MaxSalary);
// }
[Fact]
public async Task Group_API_Test()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = await _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).ToListAsync();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public async Task Group_API_Test1()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = await _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderBy(o => o.TotalSalary).ToListAsync();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("200", group[0].GroupUserId);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public async Task Group_API_Test2()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = await _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderByDescending(o => o.TotalSalary).ToListAsync();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("300", group[0].GroupUserId);
Assert.Equal(2690000, group[0].TotalSalary);
Assert.Equal(1345000, group[0].AvgSalary);
Assert.Equal(13450, group[0].AvgSalaryDecimal);
Assert.Equal(1330000, group[0].MinSalary);
Assert.Equal(1360000, group[0].MaxSalary);
}
}
}
109 changes: 83 additions & 26 deletions test/ShardingCore.Test2x/ShardingTestSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,31 +1454,88 @@ public void QueryInner_Test()
var sysUserModInts = _virtualDbContext.Set<SysUserModInt>().Where(o => sysUserMods.Select(i => i.Age).Any(i => i == o.Age)).ToList();
Assert.Equal(1000, sysUserModInts.Count);
}
// [Fact]
// public void Group_API_Test()
// {
// var ids = new[] {"200", "300"};
// var dateOfMonths = new[] {202111, 202110};
// var group = _virtualDbContext.Set<SysUserSalary>()
// .Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
// .ShardingGroupBy(g => new {UId = g.UserId}, g => new
// {
//
// GroupUserId = g.Key.UId,
// Count = g.Count(),
// TotalSalary = g.Sum(o => o.Salary),
// AvgSalary = g.Average(o => o.Salary),
// AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
// MinSalary = g.Min(o => o.Salary),
// MaxSalary = g.Max(o => o.Salary)
// });
// Assert.Equal(2, group.Count);
// Assert.Equal(2, group[0].Count);
// Assert.Equal(2260000, group[0].TotalSalary);
// Assert.Equal(1130000, group[0].AvgSalary);
// Assert.Equal(11300, group[0].AvgSalaryDecimal);
// Assert.Equal(1120000, group[0].MinSalary);
// Assert.Equal(1140000, group[0].MaxSalary);
// }
[Fact]
public void Group_API_Test()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public void Group_API_Test1()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderBy(o => o.TotalSalary).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("200", group[0].GroupUserId);
Assert.Equal(2260000, group[0].TotalSalary);
Assert.Equal(1130000, group[0].AvgSalary);
Assert.Equal(11300, group[0].AvgSalaryDecimal);
Assert.Equal(1120000, group[0].MinSalary);
Assert.Equal(1140000, group[0].MaxSalary);
}
[Fact]
public void Group_API_Test2()
{
var ids = new[] { "200", "300" };
var dateOfMonths = new[] { 202111, 202110 };
var group = _virtualDbContext.Set<SysUserSalary>()
.Where(o => ids.Contains(o.UserId) && dateOfMonths.Contains(o.DateOfMonth))
.GroupBy(g => new { UId = g.UserId })
.Select(g => new
{
GroupUserId = g.Key.UId,
Count = g.Count(),
TotalSalary = g.Sum(o => o.Salary),
AvgSalary = g.Average(o => o.Salary),
AvgSalaryDecimal = g.Average(o => o.SalaryDecimal),
MinSalary = g.Min(o => o.Salary),
MaxSalary = g.Max(o => o.Salary)
}).OrderByDescending(o => o.TotalSalary).ToList();
Assert.Equal(2, group.Count);
Assert.Equal(2, group[0].Count);
Assert.Equal("300", group[0].GroupUserId);
Assert.Equal(2690000, group[0].TotalSalary);
Assert.Equal(1345000, group[0].AvgSalary);
Assert.Equal(13450, group[0].AvgSalaryDecimal);
Assert.Equal(1330000, group[0].MinSalary);
Assert.Equal(1360000, group[0].MaxSalary);
}
}
}
Loading

0 comments on commit 34c3844

Please sign in to comment.