diff --git a/Directory.Build.targets b/Directory.Build.targets
index d030c24ba28..325ff7c0196 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -18,14 +18,4 @@
-
-
-
-
- reactive
-
-
-
diff --git a/benchmark/EFCore.SqlServer.Benchmarks/EFCore.SqlServer.Benchmarks.csproj b/benchmark/EFCore.SqlServer.Benchmarks/EFCore.SqlServer.Benchmarks.csproj
index c8e2081f22a..c1884b89fd2 100644
--- a/benchmark/EFCore.SqlServer.Benchmarks/EFCore.SqlServer.Benchmarks.csproj
+++ b/benchmark/EFCore.SqlServer.Benchmarks/EFCore.SqlServer.Benchmarks.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0
+ netcoreapp3.0
Microsoft.EntityFrameworkCore.Benchmarks
Exe
diff --git a/benchmark/EFCore.Sqlite.Benchmarks/EFCore.Sqlite.Benchmarks.csproj b/benchmark/EFCore.Sqlite.Benchmarks/EFCore.Sqlite.Benchmarks.csproj
index e5f227bdcf8..858477ef9c7 100644
--- a/benchmark/EFCore.Sqlite.Benchmarks/EFCore.Sqlite.Benchmarks.csproj
+++ b/benchmark/EFCore.Sqlite.Benchmarks/EFCore.Sqlite.Benchmarks.csproj
@@ -2,6 +2,7 @@
net461;netcoreapp2.0;netcoreapp2.1;netcoreapp2.2;netcoreapp3.0
+ netcoreapp3.0
Microsoft.EntityFrameworkCore.Benchmarks
Exe
diff --git a/eng/Versions.props b/eng/Versions.props
index 145ef8777de..fe967bcac8f 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -24,7 +24,6 @@
1.1.12
1.1.12
1.1.1-beta.61
- 3.2.0
0.11.3
1.0.19128.1-Preview
diff --git a/src/EFCore.Abstractions/EFCore.Abstractions.csproj b/src/EFCore.Abstractions/EFCore.Abstractions.csproj
index 9eaa6bdf25b..eac661300e4 100644
--- a/src/EFCore.Abstractions/EFCore.Abstractions.csproj
+++ b/src/EFCore.Abstractions/EFCore.Abstractions.csproj
@@ -2,7 +2,7 @@
Provides abstractions and attributes that are used to configure Entity Framework Core
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.Abstractions
Microsoft.EntityFrameworkCore
diff --git a/src/EFCore.Cosmos/EFCore.Cosmos.csproj b/src/EFCore.Cosmos/EFCore.Cosmos.csproj
index b0a0ad17f0d..44922d8609e 100644
--- a/src/EFCore.Cosmos/EFCore.Cosmos.csproj
+++ b/src/EFCore.Cosmos/EFCore.Cosmos.csproj
@@ -2,7 +2,7 @@
Azure Cosmos provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.Cosmos
Microsoft.EntityFrameworkCore.Cosmos
diff --git a/src/EFCore.Cosmos/Query/Expressions/Internal/DocumentQueryExpression.cs b/src/EFCore.Cosmos/Query/Expressions/Internal/DocumentQueryExpression.cs
index 55e02cfe1e7..97b8ab23fea 100644
--- a/src/EFCore.Cosmos/Query/Expressions/Internal/DocumentQueryExpression.cs
+++ b/src/EFCore.Cosmos/Query/Expressions/Internal/DocumentQueryExpression.cs
@@ -31,7 +31,7 @@ public DocumentQueryExpression(bool async, string collectionId, SelectExpression
public override Expression Reduce()
=> Call(
_async ? _queryAsyncMethodInfo : _queryMethodInfo,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Constant(_collectionId),
Constant(SelectExpression));
diff --git a/src/EFCore.Cosmos/Query/Expressions/Internal/QueryShaperExpression.cs b/src/EFCore.Cosmos/Query/Expressions/Internal/QueryShaperExpression.cs
index 5ee58ebba89..0dd2ed4701f 100644
--- a/src/EFCore.Cosmos/Query/Expressions/Internal/QueryShaperExpression.cs
+++ b/src/EFCore.Cosmos/Query/Expressions/Internal/QueryShaperExpression.cs
@@ -82,23 +82,28 @@ public AsyncShaperEnumerable(
_shaper = shaper;
}
- public IAsyncEnumerator GetEnumerator() => new AsyncShaperEnumerator(this);
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ {
+ return new AsyncShaperEnumerator(this, cancellationToken);
+ }
private class AsyncShaperEnumerator : IAsyncEnumerator
{
private readonly IAsyncEnumerator _enumerator;
private readonly Func _shaper;
- public AsyncShaperEnumerator(AsyncShaperEnumerable enumerable)
+ public AsyncShaperEnumerator(AsyncShaperEnumerable enumerable, CancellationToken cancellationToken)
{
- _enumerator = enumerable._innerEnumerable.GetEnumerator();
+ _enumerator = enumerable._innerEnumerable.GetAsyncEnumerator(cancellationToken);
_shaper = enumerable._shaper;
}
+ public T Current { get; private set; }
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public async Task MoveNext(CancellationToken cancellationToken)
+ public async ValueTask MoveNextAsync()
{
- if (!await _enumerator.MoveNext(cancellationToken))
+ if (!await _enumerator.MoveNextAsync())
{
Current = default;
return false;
@@ -108,9 +113,12 @@ public async Task MoveNext(CancellationToken cancellationToken)
return true;
}
- public T Current { get; private set; }
+ public ValueTask DisposeAsync()
+ {
+ _enumerator.DisposeAsync();
- public void Dispose() => _enumerator.Dispose();
+ return default;
+ }
}
}
diff --git a/src/EFCore.Cosmos/Query/Internal/EntityShaper.cs b/src/EFCore.Cosmos/Query/Internal/EntityShaper.cs
index e199910d1ff..c84987e9062 100644
--- a/src/EFCore.Cosmos/Query/Internal/EntityShaper.cs
+++ b/src/EFCore.Cosmos/Query/Internal/EntityShaper.cs
@@ -47,7 +47,7 @@ public virtual LambdaExpression CreateShaperLambda()
Expression.Call(
_shapeMethodInfo,
jObjectParameter,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Expression.Constant(_trackingQuery),
entityInfo),
_entityType.ClrType),
diff --git a/src/EFCore.Cosmos/Query/Pipeline/CosmosEntityQueryableTranslatorFactory.cs b/src/EFCore.Cosmos/Query/Pipeline/CosmosEntityQueryableTranslatorFactory.cs
index e80a6ece9ce..41cc8c88f51 100644
--- a/src/EFCore.Cosmos/Query/Pipeline/CosmosEntityQueryableTranslatorFactory.cs
+++ b/src/EFCore.Cosmos/Query/Pipeline/CosmosEntityQueryableTranslatorFactory.cs
@@ -16,7 +16,7 @@ public CosmosEntityQueryableTranslatorFactory(IModel model)
_model = model;
}
- public override EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext)
+ public override EntityQueryableTranslator Create(QueryCompilationContext queryCompilationContext)
{
throw new NotImplementedException();
}
@@ -39,7 +39,7 @@ public CosmosShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerSou
_entityMaterializerSource = entityMaterializerSource;
}
- public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext)
+ public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
{
throw new NotImplementedException();
//return new CosmosShapedQueryCompilingExpressionVisitor(
diff --git a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
index a473feb763b..db36cef614a 100644
--- a/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
+++ b/src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
@@ -428,8 +428,8 @@ public DocumentAsyncEnumerable(
_cosmosSqlQuery = cosmosSqlQuery;
}
- public IAsyncEnumerator GetEnumerator() => new AsyncEnumerator(this);
-
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ => new AsyncEnumerator(this, cancellationToken);
private class AsyncEnumerator : IAsyncEnumerator
{
private CosmosResultSetIterator _query;
@@ -439,20 +439,23 @@ private class AsyncEnumerator : IAsyncEnumerator
private readonly CosmosClientWrapper _cosmosClient;
private readonly string _containerId;
private readonly CosmosSqlQuery _cosmosSqlQuery;
+ private readonly CancellationToken _cancellationToken;
- public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable)
+ public AsyncEnumerator(DocumentAsyncEnumerable documentEnumerable, CancellationToken cancellationToken)
{
_cosmosClient = documentEnumerable._cosmosClient;
_containerId = documentEnumerable._containerId;
_cosmosSqlQuery = documentEnumerable._cosmosSqlQuery;
+ _cancellationToken = cancellationToken;
}
public JObject Current { get; private set; }
+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public async Task MoveNext(CancellationToken cancellationToken)
+ public async ValueTask MoveNextAsync()
{
- cancellationToken.ThrowIfCancellationRequested();
+ _cancellationToken.ThrowIfCancellationRequested();
if (_jsonReader == null)
{
@@ -467,7 +470,7 @@ public async Task MoveNext(CancellationToken cancellationToken)
return false;
}
- _responseStream = (await _query.FetchNextSetAsync(cancellationToken)).Content;
+ _responseStream = (await _query.FetchNextSetAsync(_cancellationToken)).Content;
_reader = new StreamReader(_responseStream);
_jsonReader = new JsonTextReader(_reader);
@@ -510,10 +513,10 @@ public async Task MoveNext(CancellationToken cancellationToken)
_reader = null;
_responseStream.Dispose();
_responseStream = null;
- return await MoveNext(cancellationToken);
+ return await MoveNextAsync();
}
- public void Dispose()
+ public ValueTask DisposeAsync()
{
_jsonReader?.Close();
_jsonReader = null;
@@ -521,9 +524,9 @@ public void Dispose()
_reader = null;
_responseStream?.Dispose();
_responseStream = null;
- }
- public void Reset() => throw new NotImplementedException();
+ return default;
+ }
}
}
diff --git a/src/EFCore.Design/EFCore.Design.csproj b/src/EFCore.Design/EFCore.Design.csproj
index 5c615c3bbf8..8b274c913d0 100644
--- a/src/EFCore.Design/EFCore.Design.csproj
+++ b/src/EFCore.Design/EFCore.Design.csproj
@@ -2,7 +2,7 @@
Shared design-time components for Entity Framework Core tools.
- netstandard2.0
+ netstandard2.1
Microsoft.EntityFrameworkCore.Design
Microsoft.EntityFrameworkCore
true
@@ -20,7 +20,7 @@
build
-
+
diff --git a/src/EFCore.InMemory/EFCore.InMemory.csproj b/src/EFCore.InMemory/EFCore.InMemory.csproj
index 23f40b2f7f1..d5fa1fe00df 100644
--- a/src/EFCore.InMemory/EFCore.InMemory.csproj
+++ b/src/EFCore.InMemory/EFCore.InMemory.csproj
@@ -2,7 +2,7 @@
In-memory database provider for Entity Framework Core (to be used for testing purposes).
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.InMemory
Microsoft.EntityFrameworkCore.InMemory
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor2.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor.cs
similarity index 79%
rename from src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor2.cs
rename to src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor.cs
index d8cb2605c4d..482f3385584 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor2.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitor.cs
@@ -7,11 +7,11 @@
namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline
{
- public class InMemoryEntityQueryableExpressionVisitor2 : EntityQueryableExpressionVisitor2
+ public class InMemoryEntityQueryableExpressionVisitor : EntityQueryableExpressionVisitor
{
private readonly IModel _model;
- public InMemoryEntityQueryableExpressionVisitor2(IModel model)
+ public InMemoryEntityQueryableExpressionVisitor(IModel model)
{
_model = model;
}
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitorFactory2.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitorFactory2.cs
index 9ad399898a9..c020fe105f7 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitorFactory2.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitorFactory2.cs
@@ -15,7 +15,7 @@ public InMemoryEntityQueryableTranslatorFactory(IModel model)
_model = model;
}
- public override EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext)
+ public override EntityQueryableTranslator Create(QueryCompilationContext queryCompilationContext)
{
return new InMemoryEntityQueryableTranslator(_model);
}
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitors.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitors.cs
index b6c8928a8b3..79216d94f7d 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitors.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryEntityQueryableExpressionVisitors.cs
@@ -18,7 +18,7 @@ public InMemoryEntityQueryableTranslator(IModel model)
public override Expression Visit(Expression query)
{
- return new InMemoryEntityQueryableExpressionVisitor2(_model).Visit(query);
+ return new InMemoryEntityQueryableExpressionVisitor(_model).Visit(query);
}
}
}
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs
index d386fe407de..93825365bf3 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs
@@ -47,7 +47,7 @@ protected override Expression VisitExtension(Expression extensionExpression)
case InMemoryTableExpression inMemoryTableExpression:
return Expression.Call(
_queryMethodInfo,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Expression.Constant(inMemoryTableExpression.EntityType));
}
@@ -74,7 +74,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
var shaperLambda = Expression.Lambda(
newBody,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
enumeratorParameter);
return Expression.Call(
@@ -82,7 +82,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
? _shapeAsyncMethodInfo.MakeGenericMethod(shaperLambda.ReturnType.GetGenericArguments().Single())
: _shapeMethodInfo.MakeGenericMethod(shaperLambda.ReturnType),
innerEnumerable,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Expression.Constant(shaperLambda.Compile()),
Expression.Constant(_contextType),
Expression.Constant(_logger));
@@ -232,7 +232,8 @@ public AsyncQueryingEnumerable(
_logger = logger;
}
- public IAsyncEnumerator GetEnumerator() => new AsyncEnumerator(this);
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ => new AsyncEnumerator(this, cancellationToken);
private sealed class AsyncEnumerator : IAsyncEnumerator
{
@@ -242,21 +243,23 @@ private sealed class AsyncEnumerator : IAsyncEnumerator
private readonly Func, Task> _shaper;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
+ private readonly CancellationToken _cancellationToken;
- public AsyncEnumerator(AsyncQueryingEnumerable asyncQueryingEnumerable)
+ public AsyncEnumerator(
+ AsyncQueryingEnumerable asyncQueryingEnumerable,
+ CancellationToken cancellationToken)
{
_queryContext = asyncQueryingEnumerable._queryContext;
_innerEnumerable = asyncQueryingEnumerable._innerEnumerable;
_shaper = asyncQueryingEnumerable._shaper;
_contextType = asyncQueryingEnumerable._contextType;
_logger = asyncQueryingEnumerable._logger;
+ _cancellationToken = cancellationToken;
}
public T Current { get; private set; }
- public void Dispose() => _enumerator?.Dispose();
-
- public async Task MoveNext(CancellationToken cancellationToken)
+ public async ValueTask MoveNextAsync()
{
try
{
@@ -280,6 +283,13 @@ public async Task MoveNext(CancellationToken cancellationToken)
throw;
}
}
+
+ public ValueTask DisposeAsync()
+ {
+ _enumerator?.Dispose();
+
+ return default;
+ }
}
}
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitorFactory.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitorFactory.cs
index 4c7eac7039c..4fafa7b7770 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitorFactory.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitorFactory.cs
@@ -15,7 +15,7 @@ public InMemoryShapedQueryCompilingExpressionVisitorFactory(IEntityMaterializerS
_entityMaterializerSource = entityMaterializerSource;
}
- public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext)
+ public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
{
return new InMemoryShapedQueryCompilingExpressionVisitor(
_entityMaterializerSource,
diff --git a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryOptimizerFactory.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryOptimizerFactory.cs
index 12854a4fac8..332f39a8a53 100644
--- a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryOptimizerFactory.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryOptimizerFactory.cs
@@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.InMemory.Query.Pipeline
{
public class InMemoryShapedQueryOptimizerFactory : ShapedQueryOptimizerFactory
{
- public override ShapedQueryOptimizer Create(QueryCompilationContext2 queryCompilationContext)
+ public override ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext)
{
return new InMemoryShapedQueryOptimizer();
}
diff --git a/src/EFCore.InMemory/Query/Pipeline/Translator.cs b/src/EFCore.InMemory/Query/Pipeline/Translator.cs
index d55b2f94696..6fe1d97dcb1 100644
--- a/src/EFCore.InMemory/Query/Pipeline/Translator.cs
+++ b/src/EFCore.InMemory/Query/Pipeline/Translator.cs
@@ -90,7 +90,7 @@ protected override Expression VisitParameter(ParameterExpression parameterExpres
{
return Expression.Call(
_getParameterValueMethodInfo.MakeGenericMethod(parameterExpression.Type),
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Expression.Constant(parameterExpression.Name));
}
diff --git a/src/EFCore.Proxies/EFCore.Proxies.csproj b/src/EFCore.Proxies/EFCore.Proxies.csproj
index a2b35c3ee20..d7f9bd0f8bf 100644
--- a/src/EFCore.Proxies/EFCore.Proxies.csproj
+++ b/src/EFCore.Proxies/EFCore.Proxies.csproj
@@ -2,7 +2,7 @@
Lazy-loading proxies for EF Core.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.Proxies
Microsoft.EntityFrameworkCore
diff --git a/src/EFCore.Relational/EFCore.Relational.csproj b/src/EFCore.Relational/EFCore.Relational.csproj
index e608c8c3804..b97ea3461b7 100644
--- a/src/EFCore.Relational/EFCore.Relational.csproj
+++ b/src/EFCore.Relational/EFCore.Relational.csproj
@@ -2,7 +2,7 @@
Shared Entity Framework Core components for relational database providers.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.Relational
Microsoft.EntityFrameworkCore
diff --git a/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs b/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs
index 55a9bbd4b38..22da86366da 100644
--- a/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs
+++ b/src/EFCore.Relational/Infrastructure/EntityFrameworkRelationalServicesBuilder.cs
@@ -80,7 +80,7 @@ public static readonly IDictionary RelationalServi
{ typeof(IRelationalTypeMappingSourcePlugin), new ServiceCharacteristics(ServiceLifetime.Singleton, multipleRegistrations: true) },
// New Query Pipeline
- { typeof(IQuerySqlGeneratorFactory2), new ServiceCharacteristics(ServiceLifetime.Singleton) },
+ { typeof(IQuerySqlGeneratorFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IRelationalSqlTranslatingExpressionVisitorFactory), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IMethodCallTranslatorProvider), new ServiceCharacteristics(ServiceLifetime.Singleton) },
{ typeof(IMemberTranslatorProvider), new ServiceCharacteristics(ServiceLifetime.Singleton) },
@@ -153,7 +153,7 @@ public override EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd();
// New Query pipeline
- TryAdd();
+ TryAdd();
TryAdd();
TryAdd();
TryAdd();
diff --git a/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs
index c5d18b20d33..df71182ae00 100644
--- a/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs
+++ b/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs
@@ -20,7 +20,7 @@ private class AsyncQueryingEnumerable : IAsyncEnumerable
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func> _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
@@ -28,7 +28,7 @@ private class AsyncQueryingEnumerable : IAsyncEnumerable
public AsyncQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory,
SelectExpression selectExpression,
@@ -46,7 +46,8 @@ public AsyncQueryingEnumerable(
_logger = logger;
}
- public IAsyncEnumerator GetEnumerator() => new AsyncEnumerator(this);
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ => new AsyncEnumerator(this, cancellationToken);
private sealed class AsyncEnumerator : IAsyncEnumerator
{
@@ -55,13 +56,16 @@ private sealed class AsyncEnumerator : IAsyncEnumerator
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func> _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
+ private readonly CancellationToken _cancellationToken;
- public AsyncEnumerator(AsyncQueryingEnumerable queryingEnumerable)
+ public AsyncEnumerator(
+ AsyncQueryingEnumerable queryingEnumerable,
+ CancellationToken cancellationToken)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_shaper = queryingEnumerable._shaper;
@@ -71,24 +75,18 @@ public AsyncEnumerator(AsyncQueryingEnumerable queryingEnumerable)
_logger = queryingEnumerable._logger;
_sqlExpressionFactory = queryingEnumerable._sqlExpressionFactory;
_parameterNameGeneratorFactory = queryingEnumerable._parameterNameGeneratorFactory;
+ _cancellationToken = cancellationToken;
}
public T Current { get; private set; }
- public void Dispose()
- {
- _dataReader?.Dispose();
- _dataReader = null;
- _relationalQueryContext.Connection.Close();
- }
-
- public async Task MoveNext(CancellationToken cancellationToken)
+ public async ValueTask MoveNextAsync()
{
try
{
if (_dataReader == null)
{
- await _relationalQueryContext.Connection.OpenAsync(cancellationToken);
+ await _relationalQueryContext.Connection.OpenAsync(_cancellationToken);
try
{
@@ -104,7 +102,7 @@ public async Task MoveNext(CancellationToken cancellationToken)
_relationalQueryContext.Connection,
_relationalQueryContext.ParameterValues,
_relationalQueryContext.CommandLogger,
- cancellationToken);
+ _cancellationToken);
_resultCoordinator = new ResultCoordinator();
}
@@ -118,7 +116,7 @@ public async Task MoveNext(CancellationToken cancellationToken)
}
}
- var hasNext = _resultCoordinator.HasNext ?? await _dataReader.ReadAsync(cancellationToken);
+ var hasNext = _resultCoordinator.HasNext ?? await _dataReader.ReadAsync(_cancellationToken);
_resultCoordinator.HasNext = null;
Current
@@ -135,6 +133,15 @@ public async Task MoveNext(CancellationToken cancellationToken)
throw;
}
}
+
+ public ValueTask DisposeAsync()
+ {
+ _dataReader?.Dispose();
+ _dataReader = null;
+ _relationalQueryContext.Connection.Close();
+
+ return default;
+ }
}
}
}
diff --git a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs
index bf9bbfce221..8633b1f5e9b 100644
--- a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs
+++ b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs
@@ -21,7 +21,7 @@ private class FromSqlNonComposedAsyncQueryingEnumerable : IAsyncEnumerable
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func> _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
@@ -29,7 +29,7 @@ private class FromSqlNonComposedAsyncQueryingEnumerable : IAsyncEnumerable
public FromSqlNonComposedAsyncQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory,
SelectExpression selectExpression,
@@ -47,7 +47,8 @@ public FromSqlNonComposedAsyncQueryingEnumerable(
_logger = logger;
}
- public IAsyncEnumerator GetEnumerator() => new AsyncEnumerator(this);
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ => new AsyncEnumerator(this, cancellationToken);
private sealed class AsyncEnumerator : IAsyncEnumerator
{
@@ -56,13 +57,16 @@ private sealed class AsyncEnumerator : IAsyncEnumerator
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func> _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
+ private readonly CancellationToken _cancellationToken;
- public AsyncEnumerator(FromSqlNonComposedAsyncQueryingEnumerable queryingEnumerable)
+ public AsyncEnumerator(
+ FromSqlNonComposedAsyncQueryingEnumerable queryingEnumerable,
+ CancellationToken cancellationToken)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_shaper = queryingEnumerable._shaper;
@@ -72,19 +76,12 @@ public AsyncEnumerator(FromSqlNonComposedAsyncQueryingEnumerable queryingEnum
_logger = queryingEnumerable._logger;
_sqlExpressionFactory = queryingEnumerable._sqlExpressionFactory;
_parameterNameGeneratorFactory = queryingEnumerable._parameterNameGeneratorFactory;
+ _cancellationToken = cancellationToken;
}
public T Current { get; private set; }
-
- public void Dispose()
- {
- _dataReader?.Dispose();
- _dataReader = null;
- _relationalQueryContext.Connection.Close();
- }
-
- public async Task MoveNext(CancellationToken cancellationToken)
+ public async ValueTask MoveNextAsync()
{
try
{
@@ -108,7 +105,7 @@ public async Task MoveNext(CancellationToken cancellationToken)
_relationalQueryContext.Connection,
_relationalQueryContext.ParameterValues,
_relationalQueryContext.CommandLogger,
- cancellationToken);
+ _cancellationToken);
var readerColumns = Enumerable.Range(0, _dataReader.DbDataReader.FieldCount)
.Select(
@@ -153,7 +150,7 @@ var readerColumn
}
}
- var hasNext = await _dataReader.ReadAsync(cancellationToken);
+ var hasNext = await _dataReader.ReadAsync(_cancellationToken);
Current
= hasNext
@@ -170,7 +167,14 @@ var readerColumn
}
}
- public void Reset() => throw new NotImplementedException();
+ public ValueTask DisposeAsync()
+ {
+ _dataReader?.Dispose();
+ _dataReader = null;
+ _relationalQueryContext.Connection.Close();
+
+ return default;
+ }
}
}
}
diff --git a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedQueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedQueryingEnumerable.cs
index 3eaab6c9fce..c00e58c24a7 100644
--- a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedQueryingEnumerable.cs
+++ b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedQueryingEnumerable.cs
@@ -20,7 +20,7 @@ private class FromSqlNonComposedQueryingEnumerable : IEnumerable
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
@@ -28,7 +28,7 @@ private class FromSqlNonComposedQueryingEnumerable : IEnumerable
public FromSqlNonComposedQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory,
SelectExpression selectExpression,
@@ -56,7 +56,7 @@ private sealed class Enumerator : IEnumerator
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
diff --git a/src/EFCore.Relational/Query/Pipeline/IQuerySqlGeneratorFactory2.cs b/src/EFCore.Relational/Query/Pipeline/IQuerySqlGeneratorFactory2.cs
index 2c84da5dbb4..9831f288f40 100644
--- a/src/EFCore.Relational/Query/Pipeline/IQuerySqlGeneratorFactory2.cs
+++ b/src/EFCore.Relational/Query/Pipeline/IQuerySqlGeneratorFactory2.cs
@@ -3,7 +3,7 @@
namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
{
- public interface IQuerySqlGeneratorFactory2
+ public interface IQuerySqlGeneratorFactory
{
QuerySqlGenerator Create();
}
diff --git a/src/EFCore.Relational/Query/Pipeline/IncludeCompilingExpressionVisitor.cs b/src/EFCore.Relational/Query/Pipeline/IncludeCompilingExpressionVisitor.cs
index 9b05c8618da..5eaae56c9c4 100644
--- a/src/EFCore.Relational/Query/Pipeline/IncludeCompilingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Pipeline/IncludeCompilingExpressionVisitor.cs
@@ -164,24 +164,24 @@ protected override Expression VisitExtension(Expression extensionExpression)
var innerShaper = Visit(collectionShaper.InnerShaper);
return Expression.Call(
_includeCollectionMethodInfo.MakeGenericMethod(entityClrType, relatedEntityClrType),
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
// We don't need to visit entityExpression since it is supposed to be a parameterExpression only
includeExpression.EntityExpression,
Expression.Constant(
Expression.Lambda(
collectionShaper.OuterKeySelector,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter).Compile()),
Expression.Constant(
Expression.Lambda(
collectionShaper.InnerKeySelector,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter).Compile()),
Expression.Constant(
Expression.Lambda(
innerShaper,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
_resultCoordinatorParameter).Compile()),
Expression.Constant(includeExpression.Navigation),
@@ -198,14 +198,14 @@ protected override Expression VisitExtension(Expression extensionExpression)
var inverseNavigation = includeExpression.Navigation.FindInverse();
return Expression.Call(
_includeReferenceMethodInfo.MakeGenericMethod(entityClrType, relatedEntityClrType),
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
// We don't need to visit entityExpression since it is supposed to be a parameterExpression only
includeExpression.EntityExpression,
Expression.Constant(
Expression.Lambda(
Visit(includeExpression.NavigationExpression),
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
_resultCoordinatorParameter).Compile()),
Expression.Constant(includeExpression.Navigation),
diff --git a/src/EFCore.Relational/Query/Pipeline/QuerySqlGeneratorFactory2.cs b/src/EFCore.Relational/Query/Pipeline/QuerySqlGeneratorFactory2.cs
index 6dfab62c5fc..6a98de8d683 100644
--- a/src/EFCore.Relational/Query/Pipeline/QuerySqlGeneratorFactory2.cs
+++ b/src/EFCore.Relational/Query/Pipeline/QuerySqlGeneratorFactory2.cs
@@ -5,12 +5,12 @@
namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
{
- public class QuerySqlGeneratorFactory2 : IQuerySqlGeneratorFactory2
+ public class QuerySqlGeneratorFactory : IQuerySqlGeneratorFactory
{
private readonly IRelationalCommandBuilderFactory _commandBuilderFactory;
private readonly ISqlGenerationHelper _sqlGenerationHelper;
- public QuerySqlGeneratorFactory2(
+ public QuerySqlGeneratorFactory(
IRelationalCommandBuilderFactory commandBuilderFactory,
ISqlGenerationHelper sqlGenerationHelper)
{
diff --git a/src/EFCore.Relational/Query/Pipeline/QueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/QueryingEnumerable.cs
index 169dbc660b3..16335b0285c 100644
--- a/src/EFCore.Relational/Query/Pipeline/QueryingEnumerable.cs
+++ b/src/EFCore.Relational/Query/Pipeline/QueryingEnumerable.cs
@@ -19,14 +19,14 @@ private class QueryingEnumerable : IEnumerable
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
public QueryingEnumerable(RelationalQueryContext relationalQueryContext,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory,
SelectExpression selectExpression,
@@ -54,7 +54,7 @@ private sealed class Enumerator : IEnumerator
private readonly RelationalQueryContext _relationalQueryContext;
private readonly SelectExpression _selectExpression;
private readonly Func _shaper;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly Type _contextType;
private readonly IDiagnosticsLogger _logger;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitor2.cs b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitor2.cs
index c271707a0fc..4ef11348cb8 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitor2.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitor2.cs
@@ -11,12 +11,12 @@
namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
{
- public class RelationalEntityQueryableExpressionVisitor2 : EntityQueryableExpressionVisitor2
+ public class RelationalEntityQueryableExpressionVisitor : EntityQueryableExpressionVisitor
{
private readonly IModel _model;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
- public RelationalEntityQueryableExpressionVisitor2(IModel model, ISqlExpressionFactory sqlExpressionFactory)
+ public RelationalEntityQueryableExpressionVisitor(IModel model, ISqlExpressionFactory sqlExpressionFactory)
{
_model = model;
_sqlExpressionFactory = sqlExpressionFactory;
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitorFactory2.cs b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitorFactory2.cs
index 0b430035528..9e8be03066d 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitorFactory2.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitorFactory2.cs
@@ -17,7 +17,7 @@ public RelationalEntityQueryableTranslatorFactory(IModel model, ISqlExpressionFa
_sqlExpressionFactory = sqlExpressionFactory;
}
- public override EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext)
+ public override EntityQueryableTranslator Create(QueryCompilationContext queryCompilationContext)
{
return new RelationalEntityQueryableTranslator(_model, _sqlExpressionFactory);
}
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitors.cs b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitors.cs
index 14a15509d49..ce6a03a32d1 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitors.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalEntityQueryableExpressionVisitors.cs
@@ -20,7 +20,7 @@ public RelationalEntityQueryableTranslator(IModel model, ISqlExpressionFactory s
public override Expression Visit(Expression query)
{
- return new RelationalEntityQueryableExpressionVisitor2(_model, _sqlExpressionFactory).Visit(query);
+ return new RelationalEntityQueryableExpressionVisitor(_model, _sqlExpressionFactory).Visit(query);
}
}
}
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalProjectionBindingExpressionVisitor.cs b/src/EFCore.Relational/Query/Pipeline/RelationalProjectionBindingExpressionVisitor.cs
index 84edc158b79..cf01cff639d 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalProjectionBindingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalProjectionBindingExpressionVisitor.cs
@@ -90,7 +90,7 @@ public override Expression Visit(Expression expression)
{
return Expression.Call(
_getParameterValueMethodInfo.MakeGenericMethod(parameterExpression.Type),
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
Expression.Constant(parameterExpression.Name));
}
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryCompilingExpressionVisitor.cs b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryCompilingExpressionVisitor.cs
index 77bec53f188..f17665a5ff0 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryCompilingExpressionVisitor.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryCompilingExpressionVisitor.cs
@@ -16,7 +16,7 @@ namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
{
public partial class RelationalShapedQueryCompilingExpressionVisitor : ShapedQueryCompilingExpressionVisitor
{
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
private readonly Type _contextType;
@@ -26,7 +26,7 @@ private static ParameterExpression _resultCoordinatorParameter
public RelationalShapedQueryCompilingExpressionVisitor(
IEntityMaterializerSource entityMaterializerSource,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory,
Type contextType,
@@ -59,7 +59,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
var remappedShaperLambda =
Expression.Lambda(
shaperBody,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
indexMapParameter);
@@ -67,7 +67,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
Async
? typeof(FromSqlNonComposedAsyncQueryingEnumerable<>).MakeGenericType(remappedShaperLambda.ReturnType.GetGenericArguments().Single()).GetConstructors()[0]
: typeof(FromSqlNonComposedQueryingEnumerable<>).MakeGenericType(remappedShaperLambda.ReturnType).GetConstructors()[0],
- Expression.Convert(QueryCompilationContext2.QueryContextParameter, typeof(RelationalQueryContext)),
+ Expression.Convert(QueryCompilationContext.QueryContextParameter, typeof(RelationalQueryContext)),
Expression.Constant(_querySqlGeneratorFactory),
Expression.Constant(_sqlExpressionFactory),
Expression.Constant(_parameterNameGeneratorFactory),
@@ -79,7 +79,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
var shaperLambda = Expression.Lambda(
shaperBody,
- QueryCompilationContext2.QueryContextParameter,
+ QueryCompilationContext.QueryContextParameter,
RelationalProjectionBindingRemovingExpressionVisitor.DataReaderParameter,
_resultCoordinatorParameter);
@@ -87,7 +87,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
{
return Expression.New(
typeof(AsyncQueryingEnumerable<>).MakeGenericType(shaperLambda.ReturnType.GetGenericArguments().Single()).GetConstructors()[0],
- Expression.Convert(QueryCompilationContext2.QueryContextParameter, typeof(RelationalQueryContext)),
+ Expression.Convert(QueryCompilationContext.QueryContextParameter, typeof(RelationalQueryContext)),
Expression.Constant(_querySqlGeneratorFactory),
Expression.Constant(_sqlExpressionFactory),
Expression.Constant(_parameterNameGeneratorFactory),
@@ -99,7 +99,7 @@ protected override Expression VisitShapedQueryExpression(ShapedQueryExpression s
return Expression.New(
typeof(QueryingEnumerable<>).MakeGenericType(shaperLambda.ReturnType).GetConstructors()[0],
- Expression.Convert(QueryCompilationContext2.QueryContextParameter, typeof(RelationalQueryContext)),
+ Expression.Convert(QueryCompilationContext.QueryContextParameter, typeof(RelationalQueryContext)),
Expression.Constant(_querySqlGeneratorFactory),
Expression.Constant(_sqlExpressionFactory),
Expression.Constant(_parameterNameGeneratorFactory),
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryExpressionVisitorFactory.cs b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryExpressionVisitorFactory.cs
index e1d0747879b..41f1c63497d 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryExpressionVisitorFactory.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryExpressionVisitorFactory.cs
@@ -10,13 +10,13 @@ namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
public class RelationalShapedQueryCompilingExpressionVisitorFactory : IShapedQueryCompilingExpressionVisitorFactory
{
private readonly IEntityMaterializerSource _entityMaterializerSource;
- private readonly IQuerySqlGeneratorFactory2 _querySqlGeneratorFactory;
+ private readonly IQuerySqlGeneratorFactory _querySqlGeneratorFactory;
private readonly ISqlExpressionFactory _sqlExpressionFactory;
private readonly IParameterNameGeneratorFactory _parameterNameGeneratorFactory;
public RelationalShapedQueryCompilingExpressionVisitorFactory(
IEntityMaterializerSource entityMaterializerSource,
- IQuerySqlGeneratorFactory2 querySqlGeneratorFactory,
+ IQuerySqlGeneratorFactory querySqlGeneratorFactory,
ISqlExpressionFactory sqlExpressionFactory,
IParameterNameGeneratorFactory parameterNameGeneratorFactory)
{
@@ -26,7 +26,7 @@ public RelationalShapedQueryCompilingExpressionVisitorFactory(
_parameterNameGeneratorFactory = parameterNameGeneratorFactory;
}
- public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext)
+ public ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext)
{
return new RelationalShapedQueryCompilingExpressionVisitor(
_entityMaterializerSource,
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitors.cs b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitors.cs
index e015912a890..e67158fa637 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitors.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitors.cs
@@ -10,10 +10,10 @@ namespace Microsoft.EntityFrameworkCore.Relational.Query.Pipeline
{
public class RelationalShapedQueryOptimizer : ShapedQueryOptimizer
{
- private readonly QueryCompilationContext2 _queryCompilationContext;
+ private readonly QueryCompilationContext _queryCompilationContext;
public RelationalShapedQueryOptimizer(
- QueryCompilationContext2 queryCompilationContext,
+ QueryCompilationContext queryCompilationContext,
ISqlExpressionFactory sqlExpressionFactory)
{
_queryCompilationContext = queryCompilationContext;
diff --git a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitorsFactory.cs b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitorsFactory.cs
index 9b8d4766475..cd0f3f4c56b 100644
--- a/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitorsFactory.cs
+++ b/src/EFCore.Relational/Query/Pipeline/RelationalShapedQueryOptimizingExpressionVisitorsFactory.cs
@@ -14,7 +14,7 @@ public RelationalShapedQueryOptimizerFactory(ISqlExpressionFactory sqlExpression
SqlExpressionFactory = sqlExpressionFactory;
}
- public override ShapedQueryOptimizer Create(QueryCompilationContext2 queryCompilationContext)
+ public override ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext)
{
return new RelationalShapedQueryOptimizer(queryCompilationContext, SqlExpressionFactory);
}
diff --git a/src/EFCore.SqlServer.NTS/EFCore.SqlServer.NTS.csproj b/src/EFCore.SqlServer.NTS/EFCore.SqlServer.NTS.csproj
index b625680c3e2..5d9c9d58c0b 100644
--- a/src/EFCore.SqlServer.NTS/EFCore.SqlServer.NTS.csproj
+++ b/src/EFCore.SqlServer.NTS/EFCore.SqlServer.NTS.csproj
@@ -2,7 +2,7 @@
NetTopologySuite support for the Microsoft SQL Server database provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite
Microsoft.EntityFrameworkCore.SqlServer
diff --git a/src/EFCore.SqlServer/EFCore.SqlServer.csproj b/src/EFCore.SqlServer/EFCore.SqlServer.csproj
index 35dfa22de64..73cf7177bb2 100644
--- a/src/EFCore.SqlServer/EFCore.SqlServer.csproj
+++ b/src/EFCore.SqlServer/EFCore.SqlServer.csproj
@@ -2,7 +2,7 @@
Microsoft SQL Server database provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.SqlServer
diff --git a/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitors.cs b/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitors.cs
index 020992d9724..5934c9553d3 100644
--- a/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitors.cs
+++ b/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitors.cs
@@ -10,7 +10,7 @@ namespace Microsoft.EntityFrameworkCore.SqlServer.Query.Pipeline
public class SqlServerShapedQueryOptimizer : RelationalShapedQueryOptimizer
{
public SqlServerShapedQueryOptimizer(
- QueryCompilationContext2 queryCompilationContext,
+ QueryCompilationContext queryCompilationContext,
ISqlExpressionFactory sqlExpressionFactory)
: base(queryCompilationContext, sqlExpressionFactory)
{
diff --git a/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs b/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs
index 72fbea5e4ed..79634821e76 100644
--- a/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs
+++ b/src/EFCore.SqlServer/Query/Pipeline/SqlServerShapedQueryOptimizingExpressionVisitorsFactory.cs
@@ -13,7 +13,7 @@ public SqlServerShapedQueryOptimizerFactory(ISqlExpressionFactory sqlExpressionF
{
}
- public override ShapedQueryOptimizer Create(QueryCompilationContext2 queryCompilationContext)
+ public override ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext)
{
return new SqlServerShapedQueryOptimizer(queryCompilationContext, SqlExpressionFactory);
}
diff --git a/src/EFCore.Sqlite.Core/EFCore.Sqlite.Core.csproj b/src/EFCore.Sqlite.Core/EFCore.Sqlite.Core.csproj
index ec3db282304..f8cec9a9c03 100644
--- a/src/EFCore.Sqlite.Core/EFCore.Sqlite.Core.csproj
+++ b/src/EFCore.Sqlite.Core/EFCore.Sqlite.Core.csproj
@@ -5,7 +5,7 @@
Microsoft.EntityFrameworkCore.Sqlite.Core
Microsoft.EntityFrameworkCore.Sqlite
SQLite database provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
true
$(PackageTags);SQLite
diff --git a/src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs b/src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs
index 93dc290af35..719ad274d16 100644
--- a/src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs
+++ b/src/EFCore.Sqlite.Core/Infrastructure/SqliteServiceCollectionExtensions.cs
@@ -80,7 +80,7 @@ public static IServiceCollection AddEntityFrameworkSqlite([NotNull] this IServic
// New Query Pipeline
.TryAdd()
.TryAdd()
- .TryAdd()
+ .TryAdd()
.TryAdd()
.TryAddProviderSpecificServices(
diff --git a/src/EFCore.Sqlite.Core/Query/Pipeline/SqliteQuerySqlGeneratorFactory2.cs b/src/EFCore.Sqlite.Core/Query/Pipeline/SqliteQuerySqlGeneratorFactory2.cs
index 0c65ccc7262..27af19bc142 100644
--- a/src/EFCore.Sqlite.Core/Query/Pipeline/SqliteQuerySqlGeneratorFactory2.cs
+++ b/src/EFCore.Sqlite.Core/Query/Pipeline/SqliteQuerySqlGeneratorFactory2.cs
@@ -6,12 +6,12 @@
namespace Microsoft.EntityFrameworkCore.Sqlite.Query.Pipeline
{
- public class SqliteQuerySqlGeneratorFactory2 : QuerySqlGeneratorFactory2
+ public class SqliteQuerySqlGeneratorFactory : QuerySqlGeneratorFactory
{
private readonly IRelationalCommandBuilderFactory _commandBuilderFactory;
private readonly ISqlGenerationHelper _sqlGenerationHelper;
- public SqliteQuerySqlGeneratorFactory2(
+ public SqliteQuerySqlGeneratorFactory(
IRelationalCommandBuilderFactory commandBuilderFactory,
ISqlGenerationHelper sqlGenerationHelper)
: base(commandBuilderFactory, sqlGenerationHelper)
diff --git a/src/EFCore.Sqlite.NTS/EFCore.Sqlite.NTS.csproj b/src/EFCore.Sqlite.NTS/EFCore.Sqlite.NTS.csproj
index 85d935382b8..215f5642b92 100644
--- a/src/EFCore.Sqlite.NTS/EFCore.Sqlite.NTS.csproj
+++ b/src/EFCore.Sqlite.NTS/EFCore.Sqlite.NTS.csproj
@@ -5,7 +5,7 @@
Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite
Microsoft.EntityFrameworkCore.Sqlite
NetTopologySuite support for the SQLite database provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
true
$(PackageTags);SQLite;GIS;NTS;OGC;SpatiaLite
diff --git a/src/EFCore.Sqlite/EFCore.Sqlite.csproj b/src/EFCore.Sqlite/EFCore.Sqlite.csproj
index 3a5829057f8..0163f33a067 100644
--- a/src/EFCore.Sqlite/EFCore.Sqlite.csproj
+++ b/src/EFCore.Sqlite/EFCore.Sqlite.csproj
@@ -4,7 +4,7 @@
SQLite database provider for Entity Framework Core.
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore.Sqlite
$(PackageTags);SQLite
diff --git a/src/EFCore.Sqlite/lib/netstandard2.0/_._ b/src/EFCore.Sqlite/lib/netstandard2.1/_._
similarity index 100%
rename from src/EFCore.Sqlite/lib/netstandard2.0/_._
rename to src/EFCore.Sqlite/lib/netstandard2.1/_._
diff --git a/src/EFCore.Tools/lib/netstandard2.0/_._ b/src/EFCore.Tools/lib/netstandard2.1/_._
similarity index 100%
rename from src/EFCore.Tools/lib/netstandard2.0/_._
rename to src/EFCore.Tools/lib/netstandard2.1/_._
diff --git a/src/EFCore/EF.CompileAsyncQuery.cs b/src/EFCore/EF.CompileAsyncQuery.cs
index 4adc770ac5b..2af88eef194 100644
--- a/src/EFCore/EF.CompileAsyncQuery.cs
+++ b/src/EFCore/EF.CompileAsyncQuery.cs
@@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
+using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
@@ -22,7 +23,7 @@ public static partial class EF
/// The query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery(
+ public static Func> CompileAsyncQuery(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
where TResult : class
@@ -36,7 +37,7 @@ public static Func> CompileAsyncQueryThe LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
[Obsolete("Use DbSet instead")]
- public static Func> CompileAsyncQuery(
+ public static Func> CompileAsyncQuery(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
where TResult : class
@@ -49,7 +50,7 @@ public static Func> CompileAsyncQueryThe query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery(
+ public static Func> CompileAsyncQuery(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
=> new CompiledAsyncEnumerableQuery(queryExpression).Execute;
@@ -62,7 +63,7 @@ public static Func> CompileAsyncQueryThe query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery(
+ public static Func> CompileAsyncQuery(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
=> new CompiledAsyncEnumerableQuery(queryExpression).Execute;
@@ -76,7 +77,7 @@ public static Func> CompileAsyncQuer
/// The query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery<
+ public static Func> CompileAsyncQuery<
TContext, TParam1, TParam2, TResult>(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
@@ -92,7 +93,7 @@ public static Func> Compile
/// The query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery<
+ public static Func> CompileAsyncQuery<
TContext, TParam1, TParam2, TParam3, TResult>(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
@@ -109,7 +110,7 @@ public static Func
/// The query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery<
+ public static Func> CompileAsyncQuery<
TContext, TParam1, TParam2, TParam3, TParam4, TResult>(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
@@ -127,7 +128,7 @@ public static FuncThe query result type.
/// The LINQ query expression.
/// A delegate that can be invoked to execute the compiled query.
- public static Func> CompileAsyncQuery<
+ public static Func> CompileAsyncQuery<
TContext, TParam1, TParam2, TParam3, TParam4, TParam5, TResult>(
[NotNull] Expression>> queryExpression)
where TContext : DbContext
diff --git a/src/EFCore/EFCore.csproj b/src/EFCore/EFCore.csproj
index 1216c467c02..15175a90f11 100644
--- a/src/EFCore/EFCore.csproj
+++ b/src/EFCore/EFCore.csproj
@@ -7,7 +7,7 @@ Commonly Used Types:
Microsoft.EntityFrameworkCore.DbContext
Microsoft.EntityFrameworkCore.DbSet
- netstandard2.0
+ netstandard2.1
3.6
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore
@@ -29,7 +29,6 @@ Microsoft.EntityFrameworkCore.DbSet
-
diff --git a/src/EFCore/EntityFrameworkEnumerableExtensions.cs b/src/EFCore/EntityFrameworkEnumerableExtensions.cs
new file mode 100644
index 00000000000..574dcfee82c
--- /dev/null
+++ b/src/EFCore/EntityFrameworkEnumerableExtensions.cs
@@ -0,0 +1,440 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using JetBrains.Annotations;
+using Microsoft.EntityFrameworkCore.Extensions.Internal;
+using Microsoft.EntityFrameworkCore.Utilities;
+
+// ReSharper disable once CheckNamespace
+namespace Microsoft.EntityFrameworkCore
+{
+ public static class EntityFrameworkEnumerableExtensions
+ {
+ #region ToList/Array
+
+ ///
+ /// Asynchronously creates a from an by enumerating it
+ /// asynchronously.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// An to create a list from.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains elements from the input sequence.
+ ///
+ public static async Task> ToListAsync(
+ [NotNull] this IAsyncEnumerable source,
+ CancellationToken cancellationToken = default)
+ {
+ var list = new List();
+ await foreach (var element in source.WithCancellation(cancellationToken))
+ {
+ list.Add(element);
+ }
+
+ return list;
+ }
+
+ ///
+ /// Asynchronously creates an array from an by enumerating it asynchronously.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// An to create an array from.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains an array that contains elements from the input sequence.
+ ///
+ public static async Task ToArrayAsync(
+ [NotNull] this IAsyncEnumerable source,
+ CancellationToken cancellationToken = default)
+ => (await source.ToListAsync(cancellationToken)).ToArray();
+
+ #endregion
+
+ #region ToDictionary
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains selected keys and values.
+ ///
+ public static Task> ToDictionaryAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ CancellationToken cancellationToken = default)
+ => ToDictionaryAsync(source, keySelector, e => e, comparer: null, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function and a comparer.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ ///
+ /// An to compare keys.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains selected keys and values.
+ ///
+ public static Task> ToDictionaryAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] IEqualityComparer comparer,
+ CancellationToken cancellationToken = default)
+ => ToDictionaryAsync(source, keySelector, e => e, comparer, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector and an element selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// The type of the value returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ /// A transform function to produce a result element value from each element.
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains values of type
+ /// selected from the input sequence.
+ ///
+ public static Task> ToDictionaryAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] Func elementSelector,
+ CancellationToken cancellationToken = default)
+ => ToDictionaryAsync(source, keySelector, elementSelector, comparer: null, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function, a comparer, and an element selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// The type of the value returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ /// A transform function to produce a result element value from each element.
+ ///
+ /// An to compare keys.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains values of type
+ /// selected from the input sequence.
+ ///
+ public static async Task> ToDictionaryAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] Func elementSelector,
+ [NotNull] IEqualityComparer comparer,
+ CancellationToken cancellationToken = default)
+ {
+ Check.NotNull(source, nameof(source));
+ Check.NotNull(keySelector, nameof(keySelector));
+ Check.NotNull(elementSelector, nameof(elementSelector));
+ Check.NotNull(comparer, nameof(comparer));
+
+ var d = new Dictionary(comparer);
+ await foreach (var element in source.WithCancellation(cancellationToken))
+ {
+ d.Add(keySelector(element), elementSelector(element));
+ }
+
+ return d;
+ }
+
+ #endregion
+
+ #region ToLookup
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains selected keys and values.
+ ///
+ public static Task> ToLookupAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ CancellationToken cancellationToken = default)
+ => ToLookupAsync(source, keySelector, e => e, comparer: null, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function and a comparer.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ ///
+ /// An to compare keys.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains selected keys and values.
+ ///
+ public static Task> ToLookupAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] IEqualityComparer comparer,
+ CancellationToken cancellationToken = default)
+ => ToLookupAsync(source, keySelector, e => e, comparer, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector and an element selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// The type of the value returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ /// A transform function to produce a result element value from each element.
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains values of type
+ /// selected from the input sequence.
+ ///
+ public static Task> ToLookupAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] Func elementSelector,
+ CancellationToken cancellationToken = default)
+ => ToLookupAsync(source, keySelector, elementSelector, comparer: null, cancellationToken);
+
+ ///
+ /// Creates a from an by enumerating it
+ /// asynchronously
+ /// according to a specified key selector function, a comparer, and an element selector function.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// The type of the key returned by .
+ ///
+ ///
+ /// The type of the value returned by .
+ ///
+ ///
+ /// An to create a from.
+ ///
+ /// A function to extract a key from each element.
+ /// A transform function to produce a result element value from each element.
+ ///
+ /// An to compare keys.
+ ///
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ ///
+ /// A task that represents the asynchronous operation.
+ /// The task result contains a that contains values of type
+ /// selected from the input sequence.
+ ///
+ public static Task> ToLookupAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Func keySelector,
+ [NotNull] Func elementSelector,
+ [NotNull] IEqualityComparer comparer,
+ CancellationToken cancellationToken = default)
+ {
+ Check.NotNull(source, nameof(source));
+ Check.NotNull(keySelector, nameof(keySelector));
+ Check.NotNull(elementSelector, nameof(elementSelector));
+ Check.NotNull(comparer, nameof(comparer));
+
+ throw new NotImplementedException("ToLookupAsync");
+ }
+
+ #endregion
+
+ #region ForEach
+
+ ///
+ /// Asynchronously enumerates the query results and performs the specified action on each element.
+ ///
+ ///
+ /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
+ /// that any asynchronous operations have completed before calling another method on this context.
+ ///
+ ///
+ /// The type of the elements of .
+ ///
+ ///
+ /// An to enumerate.
+ ///
+ /// The action to perform on each element.
+ ///
+ /// A to observe while waiting for the task to complete.
+ ///
+ /// A task that represents the asynchronous operation.
+ public static async Task ForEachAsync(
+ [NotNull] this IAsyncEnumerable source,
+ [NotNull] Action action,
+ CancellationToken cancellationToken = default)
+ {
+ Check.NotNull(action, nameof(action));
+
+ await foreach (var element in source.WithCancellation(cancellationToken))
+ {
+ action(element);
+ }
+ }
+
+ #endregion
+ }
+}
diff --git a/src/EFCore/EntityFrameworkQueryableExtensions.cs b/src/EFCore/EntityFrameworkQueryableExtensions.cs
index c6bc3499a13..7aba45cc4bd 100644
--- a/src/EFCore/EntityFrameworkQueryableExtensions.cs
+++ b/src/EFCore/EntityFrameworkQueryableExtensions.cs
@@ -2128,7 +2128,7 @@ public static Task ContainsAsync(
public static Task> ToListAsync(
[NotNull] this IQueryable source,
CancellationToken cancellationToken = default)
- => source.AsAsyncEnumerable().ToList(cancellationToken);
+ => source.AsAsyncEnumerable().ToListAsync(cancellationToken);
///
/// Asynchronously creates an array from an by enumerating it asynchronously.
@@ -2153,7 +2153,7 @@ public static Task> ToListAsync(
public static Task ToArrayAsync(
[NotNull] this IQueryable source,
CancellationToken cancellationToken = default)
- => source.AsAsyncEnumerable().ToArray(cancellationToken);
+ => source.AsAsyncEnumerable().ToArrayAsync(cancellationToken);
#endregion
@@ -2401,12 +2401,12 @@ public IncludableQueryable(IQueryable queryable)
public Type ElementType => _queryable.ElementType;
public IQueryProvider Provider => _queryable.Provider;
+ public IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default)
+ => ((IAsyncEnumerable)_queryable).GetAsyncEnumerator(cancellationToken);
+
public IEnumerator GetEnumerator() => _queryable.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
-
- IAsyncEnumerator IAsyncEnumerable.GetEnumerator()
- => ((IAsyncEnumerable)_queryable).GetEnumerator();
}
internal static readonly MethodInfo StringIncludeMethodInfo
@@ -2686,11 +2686,9 @@ public static async Task LoadAsync(
{
Check.NotNull(source, nameof(source));
- var asyncEnumerable = source.AsAsyncEnumerable();
-
- using (var enumerator = asyncEnumerable.GetEnumerator())
+ await using (var enumerator = source.AsAsyncEnumerable().GetAsyncEnumerator(cancellationToken))
{
- while (await enumerator.MoveNext(cancellationToken))
+ while (await enumerator.MoveNextAsync())
{
}
}
@@ -2734,7 +2732,7 @@ public static Task> ToDictionaryAsync(
Check.NotNull(source, nameof(source));
Check.NotNull(keySelector, nameof(keySelector));
- return source.AsAsyncEnumerable().ToDictionary(keySelector, cancellationToken);
+ return source.AsAsyncEnumerable().ToDictionaryAsync(keySelector, cancellationToken);
}
///
@@ -2776,7 +2774,7 @@ public static Task> ToDictionaryAsync(
Check.NotNull(keySelector, nameof(keySelector));
Check.NotNull(comparer, nameof(comparer));
- return source.AsAsyncEnumerable().ToDictionary(keySelector, comparer, cancellationToken);
+ return source.AsAsyncEnumerable().ToDictionaryAsync(keySelector, comparer, cancellationToken);
}
///
@@ -2820,7 +2818,7 @@ public static Task> ToDictionaryAsync
@@ -2869,7 +2867,7 @@ public static Task> ToDictionaryAsync> ToLookupAsync(
Check.NotNull(source, nameof(source));
Check.NotNull(keySelector, nameof(keySelector));
- return source.AsAsyncEnumerable().ToLookup(keySelector, cancellationToken);
+ return source.AsAsyncEnumerable().ToLookupAsync(keySelector, cancellationToken);
}
///
@@ -2952,7 +2950,7 @@ public static Task> ToLookupAsync(
Check.NotNull(keySelector, nameof(keySelector));
Check.NotNull(comparer, nameof(comparer));
- return source.AsAsyncEnumerable().ToLookup(keySelector, comparer, cancellationToken);
+ return source.AsAsyncEnumerable().ToLookupAsync(keySelector, comparer, cancellationToken);
}
///
@@ -2996,7 +2994,7 @@ public static Task> ToLookupAsync
@@ -3045,7 +3043,7 @@ public static Task> ToLookupAsync CoreServices
{ typeof(IResettableService), new ServiceCharacteristics(ServiceLifetime.Scoped, multipleRegistrations: true) },
// New Query related services
- { typeof(IQueryCompilationContextFactory2), new ServiceCharacteristics(ServiceLifetime.Scoped) },
+ { typeof(IQueryCompilationContextFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IQueryOptimizerFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IEntityQueryableTranslatorFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) },
{ typeof(IQueryableMethodTranslatingExpressionVisitorFactory), new ServiceCharacteristics(ServiceLifetime.Scoped) },
@@ -261,7 +261,7 @@ public virtual EntityFrameworkServicesBuilder TryAddCoreServices()
TryAdd();
// New QueryPipeline
- TryAdd();
+ TryAdd();
TryAdd();
TryAdd();
diff --git a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs
index 79461f360c7..7323a700c3d 100644
--- a/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs
+++ b/src/EFCore/Metadata/Conventions/Internal/ConventionDispatcher.cs
@@ -329,7 +329,7 @@ public virtual IConventionIndexBuilder OnIndexAdded([NotNull] IConventionIndexBu
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
///
- public virtual void OnIndexRemoved([NotNull] InternalEntityTypeBuilder entityTypeBuilder, [NotNull] Index index)
+ public virtual void OnIndexRemoved([NotNull] InternalEntityTypeBuilder entityTypeBuilder, [NotNull] Metadata.Internal.Index index)
=> _scope.OnIndexRemoved(entityTypeBuilder, index);
///
diff --git a/src/EFCore/Query/AsyncEnumerable.cs b/src/EFCore/Query/AsyncEnumerable.cs
deleted file mode 100644
index 1427464ee48..00000000000
--- a/src/EFCore/Query/AsyncEnumerable.cs
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright (c) .NET Foundation. All rights reserved.
-// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using JetBrains.Annotations;
-using Microsoft.EntityFrameworkCore.Query.Internal;
-using Microsoft.EntityFrameworkCore.Utilities;
-
-namespace Microsoft.EntityFrameworkCore.Query
-{
- ///
- /// Represents an asynchronous sequence produced by executing a compiled query.
- ///
- /// The result type.
- public readonly struct AsyncEnumerable : IAsyncEnumerableAccessor
- {
- private readonly IAsyncEnumerable _asyncEnumerable;
-
- ///
- /// Creates a new instance of
- ///
- /// The underlying instance.
- public AsyncEnumerable([NotNull] IAsyncEnumerable asyncEnumerable)
- {
- Check.NotNull(asyncEnumerable, nameof(asyncEnumerable));
-
- _asyncEnumerable = asyncEnumerable;
- }
-
- IAsyncEnumerable IAsyncEnumerableAccessor.AsyncEnumerable => _asyncEnumerable;
-
- ///
- /// Asynchronously creates a from this
- /// by enumerating it asynchronously.
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- ///
- /// A task that represents the asynchronous operation.
- /// The task result contains a that contains elements from the input sequence.
- ///
- public async Task> ToListAsync(
- CancellationToken cancellationToken = default)
- {
- var list = new List();
-
- using (var asyncEnumerator = _asyncEnumerable.GetEnumerator())
- {
- while (await asyncEnumerator.MoveNext(cancellationToken))
- {
- list.Add(asyncEnumerator.Current);
- }
- }
-
- return list;
- }
-
- ///
- /// Asynchronously creates an array from this .
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- ///
- /// A task that represents the asynchronous operation.
- /// The task result contains an array that contains elements from the input sequence.
- ///
- public async Task ToArrayAsync(
- CancellationToken cancellationToken = default)
- => (await ToListAsync(cancellationToken)).ToArray();
-
- ///
- /// Asynchronously enumerates the query. When using Entity Framework, this causes the results of the query to
- /// be loaded into the associated context. This is equivalent to calling ToList
- /// and then throwing away the list (without the overhead of actually creating the list).
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- /// A task that represents the asynchronous operation.
- public async Task LoadAsync(
- CancellationToken cancellationToken = default)
- {
- using (var enumerator = _asyncEnumerable.GetEnumerator())
- {
- while (await enumerator.MoveNext(cancellationToken))
- {
- }
- }
- }
-
- ///
- /// Creates a from this
- /// by enumerating it asynchronously according to a specified key selector function.
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// The type of the key returned by .
- ///
- /// A function to extract a key from each element.
- ///
- /// A to observe while waiting for the task to complete.
- ///
- ///
- /// A task that represents the asynchronous operation.
- /// The task result contains a that contains selected keys and values.
- ///
- public Task> ToDictionaryAsync(
- [NotNull] Func keySelector,
- CancellationToken cancellationToken = default)
- {
- Check.NotNull(keySelector, nameof(keySelector));
-
- return _asyncEnumerable.ToDictionary(keySelector, cancellationToken);
- }
-
- ///
- /// Creates a from this
- /// by enumerating it
- /// asynchronously
- /// according to a specified key selector function and a comparer.
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// The type of the key returned by .
- ///
- /// A function to extract a key from each element.
- ///
- /// An to compare keys.
- ///
- ///
- /// A to observe while waiting for the task to complete.
- ///
- ///
- /// A task that represents the asynchronous operation.
- /// The task result contains a that contains selected keys and values.
- ///
- public Task> ToDictionaryAsync(
- [NotNull] Func keySelector,
- [NotNull] IEqualityComparer comparer,
- CancellationToken cancellationToken = default)
- {
- Check.NotNull(keySelector, nameof(keySelector));
- Check.NotNull(comparer, nameof(comparer));
-
- return _asyncEnumerable.ToDictionary(keySelector, comparer, cancellationToken);
- }
-
- ///
- /// Creates a from this
- /// by enumerating it asynchronously according to a specified key selector and an element selector function.
- ///
- ///
- /// Multiple active operations on the same context instance are not supported. Use 'await' to ensure
- /// that any asynchronous operations have completed before calling another method on this context.
- ///
- ///
- /// The type of the key returned by .
- ///
- ///
- /// The type of the value returned by .
- ///
- /// A function to extract a key from each element.
- /// A transform function to produce a result element value from each element.
- ///
- /// A to observe while waiting for the task to complete.
- ///
- ///
- /// A task that represents the asynchronous operation.
- /// The task result contains a that contains values of type
- /// selected from the input sequence.
- ///
- public Task> ToDictionaryAsync(
- [NotNull] Func keySelector,
- [NotNull] Func elementSelector,
- CancellationToken cancellationToken = default)
- {
- Check.NotNull(keySelector, nameof(keySelector));
- Check.NotNull(elementSelector, nameof(elementSelector));
-
- return _asyncEnumerable.ToDictionary(keySelector, elementSelector, cancellationToken);
- }
-
- ///