diff --git a/samples/Sample.MySql/Controllers/WeatherForecastController.cs b/samples/Sample.MySql/Controllers/WeatherForecastController.cs index a40cbda6..96ef1d49 100644 --- a/samples/Sample.MySql/Controllers/WeatherForecastController.cs +++ b/samples/Sample.MySql/Controllers/WeatherForecastController.cs @@ -107,8 +107,14 @@ namespace Sample.MySql.Controllers name = o.Key.Name, count = o.Count() }).ToListAsync(); - - + var x=await (from ut in _defaultTableDbContext.Set() + from uu in _defaultTableDbContext.Set() + where ut.Id == uu.Id + select ut).FirstOrDefaultAsync(); + var x1=await (from ut in _defaultTableDbContext.Set() + from uu in _defaultTableDbContext.Set() + where ut.Id == uu.Id + select ut).FirstOrDefaultAsync(); // var firstOrDefault = _defaultTableDbContext.Set().FromSqlRaw($"select * from {nameof(SysUserMod)}").FirstOrDefault(); var sysUserMods1 = _defaultTableDbContext.Set().UseConnectionMode(1) diff --git a/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs b/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs index 346f9dc2..2809255c 100644 --- a/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs +++ b/src/ShardingCore/Sharding/Parsers/Visitors/ShardingQueryPrepareVisitor.cs @@ -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();