修复未分表的对象无法查询bug

This commit is contained in:
xuejiaming 2021-08-26 19:26:56 +08:00
parent df85bb98a0
commit daea460789
5 changed files with 24 additions and 5 deletions

View File

@ -1,8 +1,8 @@
:start
::定义版本
set EFCORE2=2.2.0.13
set EFCORE3=3.2.0.13
set EFCORE5=5.2.0.13
set EFCORE2=2.2.0.14
set EFCORE3=3.2.0.14
set EFCORE5=5.2.0.14
::删除所有bin与obj下的文件
@echo off

View File

@ -34,6 +34,18 @@ namespace Sample.SqlServer.Controllers
[HttpGet]
public async Task<IActionResult> Get()
{
var sql = from ut in _defaultTableDbContext.Set<SysTest>()
join u in _defaultTableDbContext.Set<SysUserMod>()
on ut.UserId equals u.Id
select new
{
ut.Id,
userId=u.Id
};
var listAsync =await sql.ToListAsync();
var resultx112331tt = await _defaultTableDbContext.Set<SysTest>().CountAsync();
var resultx112331 = await _defaultTableDbContext.Set<SysUserMod>().CountAsync();
var resultx11233411 = _defaultTableDbContext.Set<SysUserMod>().Count();
var resultx11231 = await _defaultTableDbContext.Set<SysUserMod>().Where(o => o.Age == 198198).Select(o => o.Id).ContainsAsync("1981");
var resultx1121 = await _defaultTableDbContext.Set<SysUserMod>().Where(o => o.Id == "198").SumAsync(o => o.Age);
var resultx111 = await _defaultTableDbContext.Set<SysUserMod>().FirstOrDefaultAsync(o => o.Id == "198");

View File

@ -32,6 +32,7 @@ namespace Sample.SqlServer
{
var ids = Enumerable.Range(1, 1000);
var userMods = new List<SysUserMod>();
var SysTests = new List<SysTest>();
foreach (var id in ids)
{
userMods.Add(new SysUserMod()
@ -40,9 +41,15 @@ namespace Sample.SqlServer
Age = id,
Name = $"name_{id}",
});
SysTests.Add(new SysTest()
{
Id = id.ToString(),
UserId = id.ToString()
});
}
virtualDbContext.AddRange(userMods);
virtualDbContext.AddRange(SysTests);
virtualDbContext.SaveChanges();
}
}

View File

@ -25,7 +25,7 @@ namespace Sample.SqlServer
services.AddShardingDbContext<DefaultShardingDbContext, DefaultTableDbContext>(
o => o.UseSqlServer("Data Source=localhost;Initial Catalog=ShardingCoreDBxx2;Integrated Security=True;")
o => o.UseSqlServer("Data Source=localhost;Initial Catalog=ShardingCoreDB;Integrated Security=True;")
, op =>
{
op.EnsureCreatedWithOutShardingTable = true;

View File

@ -22,7 +22,7 @@ namespace ShardingCore.Core.VirtualRoutes
public IRouteTail Create(RouteResult routeResult)
{
if (routeResult == null || routeResult.ReplaceTables.IsEmpty())
throw new ShardingCoreException("route result null or empty");
return new SingleQueryRouteTail(string.Empty);
if (routeResult.ReplaceTables.Count == 1)
return new SingleQueryRouteTail(routeResult);
return new MultiQueryRouteTail(routeResult);