修复cross join下无法获取分片表对象的bug

This commit is contained in:
xuejiaming 2022-11-04 23:13:49 +08:00
parent 5166bf01d7
commit a944c402a0
2 changed files with 16 additions and 4 deletions

View File

@ -107,8 +107,14 @@ namespace Sample.MySql.Controllers
name = o.Key.Name,
count = o.Count()
}).ToListAsync();
var x=await (from ut in _defaultTableDbContext.Set<SysTest>()
from uu in _defaultTableDbContext.Set<SysUserMod>()
where ut.Id == uu.Id
select ut).FirstOrDefaultAsync();
var x1=await (from ut in _defaultTableDbContext.Set<SysUserMod>()
from uu in _defaultTableDbContext.Set<SysTest>()
where ut.Id == uu.Id
select ut).FirstOrDefaultAsync();
// var firstOrDefault = _defaultTableDbContext.Set<SysUserMod>().FromSqlRaw($"select * from {nameof(SysUserMod)}").FirstOrDefault();
var sysUserMods1 = _defaultTableDbContext.Set<SysTest>().UseConnectionMode(1)

View File

@ -78,6 +78,7 @@ namespace ShardingCore.Sharding.Parsers.Visitors
return base.VisitExtension(node);
}
#endif
private void TryAddShardingEntities(Type entityType, IQueryable queryable)
{
if (!shardingEntities.ContainsKey(entityType))
@ -130,10 +131,14 @@ namespace ShardingCore.Sharding.Parsers.Visitors
case nameof(EntityFrameworkQueryableExtensions.AsNoTracking): isNoTracking = true; break;
case nameof(EntityFrameworkQueryableExtensions.AsTracking): isNoTracking = false; break;
case nameof(EntityFrameworkQueryableExtensions.IgnoreQueryFilters): isIgnoreFilter = true; break;
case nameof(EntityFrameworkQueryableExtensions.Include):
case nameof(EntityFrameworkQueryableExtensions.ThenInclude): DiscoverQueryEntities(node); break;
// case nameof(EntityFrameworkQueryableExtensions.Include):
// case nameof(EntityFrameworkQueryableExtensions.ThenInclude): DiscoverQueryEntities(node); break;
default:
{
if (node.Method.ReturnType.IsMethodReturnTypeQueryableType()&&node.Method.ReturnType.IsGenericType)
{
DiscoverQueryEntities(node);
}
var customerExpression = DiscoverCustomerQueryEntities(node);
if (customerExpression != null)
{
@ -199,6 +204,7 @@ namespace ShardingCore.Sharding.Parsers.Visitors
for (var i = 0; i < genericArguments.Length; i++)
{
var genericArgument = genericArguments[i];
if (typeof(IEnumerable).IsAssignableFrom(genericArgument))
{
var arguments = genericArgument.GetGenericArguments();