修复单个datasourcedbcontext引起的bug导致同tail会重复创建dbcontext 发布x.3.1.85修复

This commit is contained in:
xuejiaming 2021-12-17 00:56:39 +08:00
parent 75c2cf4cb8
commit 6a73e0a780
4 changed files with 27 additions and 25 deletions

View File

@ -1,9 +1,9 @@
:start
::定义版本
set EFCORE2=2.3.1.84
set EFCORE3=3.3.1.84
set EFCORE5=5.3.1.84
set EFCORE6=6.3.1.84
set EFCORE2=2.3.1.85
set EFCORE3=3.3.1.85
set EFCORE5=5.3.1.85
set EFCORE6=6.3.1.85
::删除所有bin与obj下的文件
@echo off

View File

@ -47,16 +47,21 @@ 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>().AsNoTracking().CountAsync();
//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>().AsNoTracking().CountAsync();
var resultx112331tt2 = await _defaultTableDbContext.Set<SysTest>().FirstOrDefaultAsync(o=>o.Id=="2");
var resultx112331ttaa2 = await _defaultTableDbContext.Set<SysTest>().FirstOrDefaultAsync(o=>o.Id=="2");
resultx112331ttaa2.UserId = "zzzz";
var resultx112331tt2xx = await _defaultTableDbContext.Set<SysTest>().Where(o => o.Id == "2").FirstOrDefaultAsync();
resultx112331tt2xx.UserId = "xxxxx";
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");

View File

@ -81,7 +81,7 @@ namespace ShardingCore.EFCores
}
return _shardingQueryExecutor.ExecuteAsync<TResult>(_currentContext, query, cancellationToken);
}
throw new ShardingCoreException("db context operator is not IShardingDbContext");
throw new ShardingCoreException("db context operator is not IShardingDbContext");
}
[ExcludeFromCodeCoverage]
@ -90,12 +90,6 @@ namespace ShardingCore.EFCores
throw new NotImplementedException();
}
[ExcludeFromCodeCoverage]
public Func<QueryContext, Task<TResult>> CreateCompiledAsyncTaskQuery<TResult>(Expression query)
{
throw new NotImplementedException();
}
[ExcludeFromCodeCoverage]
public Func<QueryContext, TResult> CreateCompiledAsyncQuery<TResult>(Expression query)
{

View File

@ -35,10 +35,13 @@ namespace ShardingCore.Sharding.ShardingDbContextExecutors
/// <returns></returns>
public int Compare(string? x, string? y)
{
if (_defaultTail.Equals(x))
return -1;
if (_defaultTail.Equals(y))
return 1;
if (!Object.Equals(x, y))
{
if (_defaultTail.Equals(x))
return -1;
if (_defaultTail.Equals(y))
return 1;
}
return Comparer<string>.Default.Compare(x, y);
}
}