From 702b06c556e73e702f181be88d662d3a15a8e7ba Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 3 Jun 2019 13:35:32 -0700 Subject: [PATCH 1/4] Target netstandard2.1 Microsoft.Data.Sqlite & EF tools are left intact. Most of the changes are related to breaking change on interface which IX-Async gave us and which is in built --- .../EFCore.SqlServer.Benchmarks.csproj | 1 + .../EFCore.Sqlite.Benchmarks.csproj | 1 + .../EFCore.Abstractions.csproj | 2 +- src/EFCore.Cosmos/EFCore.Cosmos.csproj | 2 +- .../Internal/QueryShaperExpression.cs | 22 +- .../Storage/Internal/CosmosClientWrapper.cs | 23 +- src/EFCore.Design/EFCore.Design.csproj | 4 +- src/EFCore.InMemory/EFCore.InMemory.csproj | 2 +- .../InMemoryShapedQueryExpressionVisitor.cs | 20 +- src/EFCore.Proxies/EFCore.Proxies.csproj | 2 +- .../EFCore.Relational.csproj | 2 +- .../Query/Pipeline/AsyncQueryingEnumerable.cs | 33 +- ...omSqlNonComposedAsyncQueryingEnumerable.cs | 32 +- .../EFCore.SqlServer.NTS.csproj | 2 +- src/EFCore.SqlServer/EFCore.SqlServer.csproj | 2 +- .../EFCore.Sqlite.Core.csproj | 2 +- .../EFCore.Sqlite.NTS.csproj | 2 +- src/EFCore.Sqlite/EFCore.Sqlite.csproj | 2 +- src/EFCore/EF.CompileAsyncQuery.cs | 17 +- src/EFCore/EFCore.csproj | 2 +- .../EntityFrameworkEnumerableExtensions.cs | 440 ++++++++++++++++++ .../EntityFrameworkQueryableExtensions.cs | 32 +- .../Internal/ConventionDispatcher.cs | 2 +- src/EFCore/Query/AsyncEnumerable.cs | 270 ----------- .../Internal/CompiledAsyncEnumerableQuery.cs | 20 +- src/EFCore/Query/Internal/EntityQueryable`.cs | 5 +- .../Pipeline/ShapedQueryExpressionVisitor.cs | 12 +- src/Shared/SharedTypeExtensions.cs | 7 - .../TestUtilities/QueryableExtensions.cs | 14 +- .../Query/AsyncSimpleQuerySqlServerTest.cs | 4 +- .../Utilities/TypeExtensionsTest.cs | 8 - 31 files changed, 583 insertions(+), 406 deletions(-) create mode 100644 src/EFCore/EntityFrameworkEnumerableExtensions.cs delete mode 100644 src/EFCore/Query/AsyncEnumerable.cs 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/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/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/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/InMemoryShapedQueryExpressionVisitor.cs b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs index d386fe407de..b1df74189f1 100644 --- a/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs +++ b/src/EFCore.InMemory/Query/Pipeline/InMemoryShapedQueryExpressionVisitor.cs @@ -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.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/Query/Pipeline/AsyncQueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs index c5d18b20d33..85f47fb6919 100644 --- a/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs +++ b/src/EFCore.Relational/Query/Pipeline/AsyncQueryingEnumerable.cs @@ -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 { @@ -60,8 +61,11 @@ private sealed class AsyncEnumerator : IAsyncEnumerator 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..ebfbc287d9c 100644 --- a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs +++ b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs @@ -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 { @@ -61,8 +62,11 @@ private sealed class AsyncEnumerator : IAsyncEnumerator 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.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.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.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/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..da6e7fda382 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 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 - 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); - } - - /// - /// Creates a from this - /// 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 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. - /// - /// 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 Task> ToDictionaryAsync( - [NotNull] Func keySelector, - [NotNull] Func elementSelector, - [NotNull] IEqualityComparer comparer, - CancellationToken cancellationToken = default) - { - Check.NotNull(keySelector, nameof(keySelector)); - Check.NotNull(elementSelector, nameof(elementSelector)); - Check.NotNull(comparer, nameof(comparer)); - - return _asyncEnumerable.ToDictionary(keySelector, elementSelector, comparer, cancellationToken); - } - - /// - /// 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 action to perform on each element. - /// - /// A to observe while waiting for the task to complete. - /// - /// A task that represents the asynchronous operation. - public async Task ForEachAsync( - [NotNull] Action action, - CancellationToken cancellationToken = default) - { - Check.NotNull(action, nameof(action)); - - using (var asyncEnumerator = _asyncEnumerable.GetEnumerator()) - { - while (await asyncEnumerator.MoveNext(cancellationToken)) - { - action(asyncEnumerator.Current); - } - } - } - } -} diff --git a/src/EFCore/Query/Internal/CompiledAsyncEnumerableQuery.cs b/src/EFCore/Query/Internal/CompiledAsyncEnumerableQuery.cs index 755c4a6a603..1e4b95c7e19 100644 --- a/src/EFCore/Query/Internal/CompiledAsyncEnumerableQuery.cs +++ b/src/EFCore/Query/Internal/CompiledAsyncEnumerableQuery.cs @@ -14,7 +14,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Internal /// 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 class CompiledAsyncEnumerableQuery : CompiledQueryBase> + public class CompiledAsyncEnumerableQuery : CompiledQueryBase> where TContext : DbContext { /// @@ -34,7 +34,7 @@ public CompiledAsyncEnumerableQuery([NotNull] LambdaExpression queryExpression) /// 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 AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context) => ExecuteCore(context); @@ -44,7 +44,7 @@ public virtual AsyncEnumerable Execute( /// 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 AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context, [CanBeNull] TParam1 param1) => ExecuteCore(context, param1); @@ -55,7 +55,7 @@ public virtual AsyncEnumerable Execute( /// 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 AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context, [CanBeNull] TParam1 param1, [CanBeNull] TParam2 param2) @@ -67,7 +67,7 @@ public virtual AsyncEnumerable Execute( /// 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 AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context, [CanBeNull] TParam1 param1, [CanBeNull] TParam2 param2, @@ -80,7 +80,7 @@ public virtual AsyncEnumerable Execute( /// 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 AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context, [CanBeNull] TParam1 param1, [CanBeNull] TParam2 param2, @@ -94,7 +94,7 @@ public virtual AsyncEnumerable Execute - public virtual AsyncEnumerable Execute( + public virtual IAsyncEnumerable Execute( [NotNull] TContext context, [CanBeNull] TParam1 param1, [CanBeNull] TParam2 param2, @@ -109,12 +109,10 @@ public virtual AsyncEnumerable Execute - protected override Func> CreateCompiledQuery( + protected override Func> CreateCompiledQuery( IQueryCompiler queryCompiler, Expression expression) { - var compiledQuery = queryCompiler.CreateCompiledAsyncQuery>(expression); - - return qc => new AsyncEnumerable(compiledQuery(qc)); + return queryCompiler.CreateCompiledAsyncQuery>(expression); } } } diff --git a/src/EFCore/Query/Internal/EntityQueryable`.cs b/src/EFCore/Query/Internal/EntityQueryable`.cs index 33fba531782..5bac44da27a 100644 --- a/src/EFCore/Query/Internal/EntityQueryable`.cs +++ b/src/EFCore/Query/Internal/EntityQueryable`.cs @@ -7,6 +7,7 @@ using System.ComponentModel; using System.Linq; using System.Linq.Expressions; +using System.Threading; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Utilities; @@ -107,8 +108,8 @@ IEnumerator IEnumerable.GetEnumerator() /// 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. /// - IAsyncEnumerator IAsyncEnumerable.GetEnumerator() - => _queryProvider.ExecuteAsync>(Expression).GetEnumerator(); + public virtual IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = default) + => _queryProvider.ExecuteAsync>(Expression).GetAsyncEnumerator(cancellationToken); /// /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to diff --git a/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs b/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs index b2598c60d17..9ebf557697f 100644 --- a/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs +++ b/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs @@ -98,16 +98,16 @@ private async static Task SingleAsync( IAsyncEnumerable asyncEnumerable, CancellationToken cancellationToken = default) { - using (var enumerator = asyncEnumerable.GetEnumerator()) + await using (var enumerator = asyncEnumerable.GetAsyncEnumerator(cancellationToken)) { - if (!(await enumerator.MoveNext(cancellationToken))) + if (!(await enumerator.MoveNextAsync())) { throw new InvalidOperationException(); } var result = enumerator.Current; - if (await enumerator.MoveNext(cancellationToken)) + if (await enumerator.MoveNextAsync()) { throw new InvalidOperationException(); } @@ -119,16 +119,16 @@ private async static Task SingleOrDefaultAsync( IAsyncEnumerable asyncEnumerable, CancellationToken cancellationToken = default) { - using (var enumerator = asyncEnumerable.GetEnumerator()) + await using (var enumerator = asyncEnumerable.GetAsyncEnumerator(cancellationToken)) { - if (!(await enumerator.MoveNext())) + if (!(await enumerator.MoveNextAsync())) { return default; } var result = enumerator.Current; - if (await enumerator.MoveNext()) + if (await enumerator.MoveNextAsync()) { throw new InvalidOperationException(); } diff --git a/src/Shared/SharedTypeExtensions.cs b/src/Shared/SharedTypeExtensions.cs index de1e78aadf5..ab839a42dd1 100644 --- a/src/Shared/SharedTypeExtensions.cs +++ b/src/Shared/SharedTypeExtensions.cs @@ -115,13 +115,6 @@ private static bool IsInstantiable(TypeInfo type) && !type.IsInterface && (!type.IsGenericType || !type.IsGenericTypeDefinition); - public static bool IsGrouping(this Type type) => IsGrouping(type.GetTypeInfo()); - - private static bool IsGrouping(TypeInfo type) - => type.IsGenericType - && (type.GetGenericTypeDefinition() == typeof(IGrouping<,>) - || type.GetGenericTypeDefinition() == typeof(IAsyncGrouping<,>)); - public static Type UnwrapEnumType(this Type type) { var isNullable = type.IsNullableType(); diff --git a/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs b/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs index 8213532f07e..dd5446f7348 100644 --- a/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs +++ b/test/EFCore.Specification.Tests/TestUtilities/QueryableExtensions.cs @@ -14,19 +14,9 @@ public static class QueryableExtensions public static List ToList(this System.Collections.IEnumerable source) => source.OfType().ToList(); - public static async Task> ToListAsync(this IQueryable source, CancellationToken cancellationToken = default) + public static Task> ToListAsync(this IQueryable source, CancellationToken cancellationToken = default) { - var list = new List(); - - using (var e = ((IQueryable)source).AsAsyncEnumerable().GetEnumerator()) - { - while (await e.MoveNext(cancellationToken).ConfigureAwait(false)) - { - list.Add(e.Current); - } - } - - return list; + return ((IQueryable)source).ToListAsync(cancellationToken); } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs index a1bbac1890f..62a36fc0dfa 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/AsyncSimpleQuerySqlServerTest.cs @@ -161,9 +161,9 @@ public async Task Concurrent_async_queries_when_raw_query() { using (var context = CreateContext()) { - using (var asyncEnumerator = context.Customers.AsAsyncEnumerable().GetEnumerator()) + await using (var asyncEnumerator = context.Customers.AsAsyncEnumerable().GetAsyncEnumerator()) { - while (await asyncEnumerator.MoveNext(default)) + while (await asyncEnumerator.MoveNextAsync()) { if (!context.GetService().IsMultipleActiveResultSetsEnabled) { diff --git a/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs b/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs index 50926c5968f..e5f03e219c2 100644 --- a/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs +++ b/test/EFCore.Tests/Utilities/TypeExtensionsTest.cs @@ -1,10 +1,6 @@ // 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. -#if NETCOREAPP3_0 -// workaround the overlap between System.Interactive.Async and System.Runtime -extern alias reactive; -#endif using System; using System.Collections; using System.Collections.Generic; @@ -25,11 +21,7 @@ public void GetSequenceType_finds_element_type() { Assert.Equal(typeof(int), typeof(IEnumerable).GetSequenceType()); Assert.Equal(typeof(int), typeof(IQueryable).GetSequenceType()); -#if NETCOREAPP3_0 - Assert.Equal(typeof(int), typeof(reactive::System.Collections.Generic.IAsyncEnumerable).GetSequenceType()); -#else Assert.Equal(typeof(int), typeof(IAsyncEnumerable).GetSequenceType()); -#endif Assert.Equal(typeof(int), typeof(List).GetSequenceType()); } From aca7c632dc0059ae27c93c70d7953a9259554429 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 3 Jun 2019 14:47:44 -0700 Subject: [PATCH 2/4] Remove dependency on IX-Async Resolves #12048 --- Directory.Build.targets | 10 ---------- eng/Versions.props | 1 - src/EFCore/EFCore.csproj | 1 - 3 files changed, 12 deletions(-) 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/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/EFCore.csproj b/src/EFCore/EFCore.csproj index da6e7fda382..15175a90f11 100644 --- a/src/EFCore/EFCore.csproj +++ b/src/EFCore/EFCore.csproj @@ -29,7 +29,6 @@ Microsoft.EntityFrameworkCore.DbSet - From 86b66da8f89911a6b734311a107105e75bd04b0b Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 3 Jun 2019 15:31:03 -0700 Subject: [PATCH 3/4] Remove traces of net461 from tests --- .../TestUtilities/BuildReference.cs | 17 - .../TestUtilities/BuildSource.cs | 16 - .../TestUtilities/TestSqlLoggerFactory.cs | 7 +- .../Storage/RelationalTypeMappingTest.cs | 5 - .../BuiltInDataTypesSqlServerTest.cs | 26 -- .../Storage/SqlServerTypeMappingTest.cs | 5 - .../Storage/NumberToStringConverterTest.cs | 5 - .../Storage/StringToNumberConverterTest.cs | 5 - .../AppDomainOperationExecutorTest.cs | 391 ------------------ test/ef.Tests/SimpleProjectTest.cs | 295 ------------- 10 files changed, 1 insertion(+), 771 deletions(-) delete mode 100644 test/ef.Tests/AppDomainOperationExecutorTest.cs delete mode 100644 test/ef.Tests/SimpleProjectTest.cs diff --git a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs index c411edf3002..490f9f79900 100644 --- a/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs +++ b/test/EFCore.Design.Tests/TestUtilities/BuildReference.cs @@ -4,17 +4,10 @@ using System; using System.Collections.Generic; using Microsoft.CodeAnalysis; -#if NETCOREAPP3_0 using Microsoft.Extensions.DependencyModel; using System.Linq; using IOPath = System.IO.Path; -#elif NET461 -using System.Reflection; - -#else -#error target frameworks need to be updated. -#endif namespace Microsoft.EntityFrameworkCore.TestUtilities { public class BuildReference @@ -33,13 +26,6 @@ private BuildReference(IEnumerable references, bool copyLocal public static BuildReference ByName(string name, bool copyLocal = false) { -#if NET461 - var assembly = Assembly.Load(name); - return new BuildReference( - new[] { MetadataReference.CreateFromFile(assembly.Location) }, - copyLocal, - new Uri(assembly.CodeBase).LocalPath); -#elif NETCOREAPP3_0 var references = (from l in DependencyContext.Default.CompileLibraries from r in l.ResolveReferencePaths() where IOPath.GetFileNameWithoutExtension(r) == name @@ -53,9 +39,6 @@ where IOPath.GetFileNameWithoutExtension(r) == name return new BuildReference( references, copyLocal); -#else -#error target frameworks need to be updated. -#endif } public static BuildReference ByPath(string path) diff --git a/test/EFCore.Design.Tests/TestUtilities/BuildSource.cs b/test/EFCore.Design.Tests/TestUtilities/BuildSource.cs index 2b578f5c48d..6b1021f59ea 100644 --- a/test/EFCore.Design.Tests/TestUtilities/BuildSource.cs +++ b/test/EFCore.Design.Tests/TestUtilities/BuildSource.cs @@ -15,19 +15,6 @@ public class BuildSource { public ICollection References { get; } = new List { -#if NET461 - BuildReference.ByName("mscorlib"), - BuildReference.ByName("netstandard"), - BuildReference.ByName("System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), - BuildReference.ByName("System.Collections.Immutable", true), - BuildReference.ByName("System.ComponentModel.Annotations", true), - BuildReference.ByName("System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"), - BuildReference.ByName("System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), - BuildReference.ByName("System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"), - BuildReference.ByName("Microsoft.Data.SqlClient", true), - BuildReference.ByName("System.Diagnostics.DiagnosticSource", true), - BuildReference.ByName("System.ValueTuple", true) -#elif NETCOREAPP3_0 BuildReference.ByName("netstandard"), BuildReference.ByName("System.Collections"), BuildReference.ByName("System.ComponentModel.Annotations"), @@ -37,9 +24,6 @@ public class BuildSource BuildReference.ByName("System.Runtime"), BuildReference.ByName("System.Runtime.Extensions"), BuildReference.ByName("System.Text.RegularExpressions") -#else -#error target frameworks need to be updated. -#endif }; public string TargetDir { get; set; } diff --git a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs index eb1acff420d..19803217365 100644 --- a/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs +++ b/test/EFCore.Relational.Specification.Tests/TestUtilities/TestSqlLoggerFactory.cs @@ -66,12 +66,7 @@ public void AssertBaseline(string[] expected, bool assertOrder = true) { var methodCallLine = Environment.StackTrace.Split( new[] { _eol }, -#if NETCOREAPP3_0 - StringSplitOptions.RemoveEmptyEntries)[3] -#else - StringSplitOptions.RemoveEmptyEntries)[4] -#endif - .Substring(6); + StringSplitOptions.RemoveEmptyEntries)[3].Substring(6); var testName = methodCallLine.Substring(0, methodCallLine.IndexOf(')') + 1); var lineIndex = methodCallLine.LastIndexOf("line", StringComparison.Ordinal); diff --git a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs index 60830c77ad9..b130ae8ba67 100644 --- a/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs +++ b/test/EFCore.Relational.Tests/Storage/RelationalTypeMappingTest.cs @@ -429,13 +429,8 @@ public virtual void Float_literal_generated_correctly() Test_GenerateSqlLiteral_helper(typeMapping, float.NaN, "NaN"); Test_GenerateSqlLiteral_helper(typeMapping, float.PositiveInfinity, "Infinity"); Test_GenerateSqlLiteral_helper(typeMapping, float.NegativeInfinity, "-Infinity"); -#if NETCOREAPP3_0 Test_GenerateSqlLiteral_helper(typeMapping, float.MinValue, "-3.4028235E+38"); Test_GenerateSqlLiteral_helper(typeMapping, float.MaxValue, "3.4028235E+38"); -#else - Test_GenerateSqlLiteral_helper(typeMapping, float.MinValue, "-3.40282347E+38"); - Test_GenerateSqlLiteral_helper(typeMapping, float.MaxValue, "3.40282347E+38"); -#endif } [Fact] diff --git a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs index f9d8635b047..c45952d7232 100644 --- a/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/BuiltInDataTypesSqlServerTest.cs @@ -1347,7 +1347,6 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_scale() var parameters = DumpParameters(); Assert.Equal( -#if NETCOREAPP3_0 @"@p0='77' @p1='2017-01-02T12:11:12' (Size = 3) @p2='2016-01-02T11:11:12.0000000+00:00' (Size = 3) @@ -1358,18 +1357,6 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_scale() @p7='85.5' (Size = 3) @p8='83.33000183105469' (Size = 25) @p9='83.3' (Size = 3)", -#else - @"@p0='77' -@p1='2017-01-02T12:11:12' (Size = 3) -@p2='2016-01-02T11:11:12.0000000+00:00' (Size = 3) -@p3='102.2' (Size = 3) -@p4='101.1' -@p5='103.3' (Size = 3) -@p6='85.5500030517578' (Size = 25) -@p7='85.5' (Size = 3) -@p8='83.3300018310547' (Size = 25) -@p9='83.3' (Size = 3)", -#endif parameters, ignoreLineEndingDifferences: true); @@ -2120,7 +2107,6 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_scale_wi var parameters = DumpParameters(); Assert.Equal( -#if NETCOREAPP3_0 @"@p0='2017-01-02T12:11:12' (Size = 3) @p1='2016-01-02T11:11:12.0000000+00:00' (Size = 3) @p2='102.2' (Size = 3) @@ -2131,18 +2117,6 @@ public virtual void Can_insert_and_read_back_all_mapped_data_types_with_scale_wi @p7='83.33000183105469' (Size = 25) @p8='83.3' (Size = 3) @p9='77'", -#else - @"@p0='2017-01-02T12:11:12' (Size = 3) -@p1='2016-01-02T11:11:12.0000000+00:00' (Size = 3) -@p2='102.2' (Size = 3) -@p3='101.1' -@p4='103.3' (Size = 3) -@p5='85.5500030517578' (Size = 25) -@p6='85.5' (Size = 3) -@p7='83.3300018310547' (Size = 25) -@p8='83.3' (Size = 3) -@p9='77'", -#endif parameters, ignoreLineEndingDifferences: true); diff --git a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs index 94f6c5962be..c3e30a7a2e8 100644 --- a/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs +++ b/test/EFCore.SqlServer.Tests/Storage/SqlServerTypeMappingTest.cs @@ -243,13 +243,8 @@ public override void Float_literal_generated_correctly() Test_GenerateSqlLiteral_helper(typeMapping, float.NaN, "CAST(NaN AS real)"); Test_GenerateSqlLiteral_helper(typeMapping, float.PositiveInfinity, "CAST(Infinity AS real)"); Test_GenerateSqlLiteral_helper(typeMapping, float.NegativeInfinity, "CAST(-Infinity AS real)"); -#if NETCOREAPP3_0 Test_GenerateSqlLiteral_helper(typeMapping, float.MinValue, "CAST(-3.4028235E+38 AS real)"); Test_GenerateSqlLiteral_helper(typeMapping, float.MaxValue, "CAST(3.4028235E+38 AS real)"); -#else - Test_GenerateSqlLiteral_helper(typeMapping, float.MinValue, "CAST(-3.40282347E+38 AS real)"); - Test_GenerateSqlLiteral_helper(typeMapping, float.MaxValue, "CAST(3.40282347E+38 AS real)"); -#endif } public override void Long_literal_generated_correctly() diff --git a/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs b/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs index 8fa521e5908..6e84770d4bb 100644 --- a/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs +++ b/test/EFCore.Tests/Storage/NumberToStringConverterTest.cs @@ -496,13 +496,8 @@ public void Can_convert_floats_to_natural_strings() { var converter = _floatToNaturalString.ConvertToProviderExpression.Compile(); -#if NETCOREAPP3_0 Assert.Equal("3.4028235E+38", converter(float.MaxValue)); Assert.Equal("-3.4028235E+38", converter(float.MinValue)); -#else - Assert.Equal("3.40282347E+38", converter(float.MaxValue)); - Assert.Equal("-3.40282347E+38", converter(float.MinValue)); -#endif Assert.Equal("-79.3335", converter((float)-79.3335)); Assert.Equal("1E-09", converter((float)0.000000001)); Assert.Equal("1E-20", converter((float)0.00000000000000000001)); diff --git a/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs b/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs index 1c116b21d49..94bfa2f2c67 100644 --- a/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs +++ b/test/EFCore.Tests/Storage/StringToNumberConverterTest.cs @@ -510,13 +510,8 @@ public void Can_convert_floats_to_natural_strings() { var converter = _naturalStringToFloat.ConvertFromProviderExpression.Compile(); -#if NETCOREAPP3_0 Assert.Equal("3.4028235E+38", converter(float.MaxValue)); Assert.Equal("-3.4028235E+38", converter(float.MinValue)); -#else - Assert.Equal("3.40282347E+38", converter(float.MaxValue)); - Assert.Equal("-3.40282347E+38", converter(float.MinValue)); -#endif Assert.Equal("-79.3335", converter((float)-79.3335)); Assert.Equal("1E-09", converter((float)0.000000001)); Assert.Equal("1E-20", converter((float)0.00000000000000000001)); diff --git a/test/ef.Tests/AppDomainOperationExecutorTest.cs b/test/ef.Tests/AppDomainOperationExecutorTest.cs deleted file mode 100644 index bbd4669ba7b..00000000000 --- a/test/ef.Tests/AppDomainOperationExecutorTest.cs +++ /dev/null @@ -1,391 +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. - -#if NET461 -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.EntityFrameworkCore.Internal; -using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.Tools.TestUtilities; -using Xunit; -using Xunit.Sdk; - -// ReSharper disable InconsistentNaming -namespace Microsoft.EntityFrameworkCore.Tools -{ - [Collection("OperationExecutorTests")] - public class AppDomainOperationExecutorTest - { - private IOperationExecutor CreateExecutorFromBuildResult( - BuildFileResult build, - string rootNamespace, - string language) - { - File.Copy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, build.TargetPath + ".config"); - - return new AppDomainOperationExecutor( - build.TargetPath, - build.TargetPath, - build.TargetDir, - build.TargetDir, - rootNamespace, - language); - } - - [Fact] - public void Assembly_load_errors_are_wrapped() - { - var targetDir = AppDomain.CurrentDomain.BaseDirectory; - using (var executor = - new AppDomainOperationExecutor(Assembly.GetExecutingAssembly().Location, Path.Combine(targetDir, "Unknown.dll"), targetDir, null, null, null)) - { - Assert.Throws(() => executor.GetContextTypes()); - } - } - - [Fact] - public void GetMigrations_filters_by_context_name() - { - using (var directory = new TempDirectory()) - { - var targetDir = directory.Path; - var source = new BuildSource - { - TargetDir = targetDir, - References = - { - BuildReference.ByName("System.Interactive.Async", true), - BuildReference.ByName("System.Threading.Tasks.Extensions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Design", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Memory", true), - BuildReference.ByName("Microsoft.Extensions.Configuration.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Logging", true), - BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Options", true), - BuildReference.ByName("Microsoft.Extensions.Primitives", true), - BuildReference.ByName("Remotion.Linq", true) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Infrastructure; - using Microsoft.EntityFrameworkCore.Migrations; - - namespace MyProject - { - internal class Context1 : DbContext - { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer(""Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SimpleProject.SimpleContext;Integrated Security=True""); - } - } - - internal class Context2 : DbContext - { - } - - namespace Migrations - { - namespace Context1Migrations - { - [DbContext(typeof(Context1))] - [Migration(""000000000000000_Context1Migration"")] - public class Context1Migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - - namespace Context2Migrations - { - [DbContext(typeof(Context2))] - [Migration(""000000000000000_Context2Migration"")] - public class Context2Migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - } - }" - } - }; - - var build = source.Build(); - using (var executor = CreateExecutorFromBuildResult(build, "MyProject", "C#")) - { - try - { - var migrations = executor.GetMigrations("Context1"); - - Assert.Single(migrations); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - } - } - - [Fact] - public void GetContextType_works_with_multiple_assemblies() - { - using (var directory = new TempDirectory()) - { - var targetDir = directory.Path; - var contextsSource = new BuildSource - { - TargetDir = targetDir, - References = - { - BuildReference.ByName("Microsoft.EntityFrameworkCore", true) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - - namespace MyProject - { - public class Context1 : DbContext - { - } - - public class Context2 : DbContext - { - } - }" - } - }; - var contextsBuild = contextsSource.Build(); - var migrationsSource = new BuildSource - { - TargetDir = targetDir, - References = - { - BuildReference.ByName("Microsoft.EntityFrameworkCore"), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Design", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Logging", true), - BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions", true), - BuildReference.ByName("System.Threading.Tasks.Extensions", true), - BuildReference.ByPath(contextsBuild.TargetPath) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Infrastructure; - using Microsoft.EntityFrameworkCore.Migrations; - - namespace MyProject - { - internal class Context3 : DbContext - { - } - - namespace Migrations - { - namespace Context1Migrations - { - [DbContext(typeof(Context1))] - [Migration(""000000000000000_Context1Migration"")] - public class Context1Migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - - namespace Context2Migrations - { - [DbContext(typeof(Context2))] - [Migration(""000000000000000_Context2Migration"")] - public class Context2Migration : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - } - }" - } - }; - var build = migrationsSource.Build(); - using (var executor = CreateExecutorFromBuildResult(build, "MyProject", "C#")) - { - try - { - var contextTypes = executor.GetContextTypes(); - - Assert.Equal(3, contextTypes.Count()); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - } - } - - [Fact] - public void AddMigration_begins_new_namespace_when_foreign_migrations() - { - using (var directory = new TempDirectory()) - { - var targetDir = directory.Path; - var source = new BuildSource - { - TargetDir = targetDir, - References = - { - BuildReference.ByName("System.Interactive.Async", true), - BuildReference.ByName("System.Threading.Tasks.Extensions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Design", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Memory", true), - BuildReference.ByName("Microsoft.Extensions.Configuration.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Logging", true), - BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Options", true), - BuildReference.ByName("Microsoft.Extensions.Primitives", true), - BuildReference.ByName("Remotion.Linq", true) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Infrastructure; - using Microsoft.EntityFrameworkCore.Migrations; - - namespace MyProject - { - internal class MyFirstContext : DbContext - { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer(""Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MyProject.MyFirstContext""); - } - } - - internal class MySecondContext : DbContext - { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer(""Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=MyProject.MySecondContext""); - } - } - - namespace Migrations - { - [DbContext(typeof(MyFirstContext))] - [Migration(""20151006140723_InitialCreate"")] - public class InitialCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - }" - } - }; - var build = source.Build(); - using (var executor = CreateExecutorFromBuildResult(build, "MyProject", "C#")) - { - try - { - var artifacts = executor.AddMigration("MyMigration", /*outputDir:*/ null, "MySecondContext"); - Assert.Equal(3, artifacts.Keys.Count); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - - Assert.True(Directory.Exists(Path.Combine(targetDir, @"Migrations\MySecond"))); - } - } - } - - [Fact] - public void Throws_for_no_parameterless_constructor() - { - using (var directory = new TempDirectory()) - { - var targetDir = directory.Path; - var source = new BuildSource - { - TargetDir = targetDir, - References = - { - BuildReference.ByName("System.Threading.Tasks.Extensions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Design", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Logging", true), - BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions", true) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Infrastructure; - using Microsoft.EntityFrameworkCore.Migrations; - - namespace MyProject - { - internal class MyContext : DbContext - { - public MyContext(DbContextOptions options) :base(options) {} - } - }" - } - }; - var build = source.Build(); - using (var executor = CreateExecutorFromBuildResult(build, "MyProject", "C#")) - { - var ex = Assert.Throws( - () => executor.GetMigrations("MyContext")); - - Assert.Equal( - DesignStrings.NoParameterlessConstructor("MyContext"), - ex.Message); - } - } - } - } -} -#elif NETCOREAPP3_0 -#else -#error target frameworks need to be updated. -#endif diff --git a/test/ef.Tests/SimpleProjectTest.cs b/test/ef.Tests/SimpleProjectTest.cs deleted file mode 100644 index a9a923c4f56..00000000000 --- a/test/ef.Tests/SimpleProjectTest.cs +++ /dev/null @@ -1,295 +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. - -#if NET461 -using System; -using System.Collections; -using System.IO; -using Microsoft.EntityFrameworkCore.TestUtilities; -using Microsoft.EntityFrameworkCore.Tools.TestUtilities; -using Xunit; - -// ReSharper disable InconsistentNaming -namespace Microsoft.EntityFrameworkCore.Tools -{ - [Collection("OperationExecutorTests")] - public class SimpleProjectTest : IClassFixture - { - private readonly SimpleProject _project; - - public SimpleProjectTest(SimpleProject project) - { - _project = project; - } - - private void AssertDefaultMigrationName(IDictionary artifacts) - => Assert.Contains("namespace SimpleProject.Migrations", File.ReadAllText(artifacts["MigrationFile"] as string)); - - [Fact] - public void AddMigration() - { - try - { - var artifacts = _project.Executor.AddMigration("EmptyMigration", "CustomFolder", "SimpleContext"); - Assert.NotNull(artifacts); - Assert.NotNull(artifacts["MigrationFile"]); - Assert.NotNull(artifacts["MetadataFile"]); - Assert.NotNull(artifacts["SnapshotFile"]); - Assert.True(Directory.Exists(Path.Combine(_project.TargetDir, "CustomFolder"))); - Assert.Contains("namespace SimpleProject.CustomFolder", File.ReadAllText(artifacts["MigrationFile"] as string)); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void AddMigration_output_dir_relative_to_projectdir() - { - try - { - var artifacts = _project.Executor.AddMigration("EmptyMigration1", "./CustomFolder", "SimpleContext"); - Assert.NotNull(artifacts); - Assert.StartsWith(Path.Combine(_project.TargetDir, "CustomFolder"), artifacts["MigrationFile"] as string); - Assert.Contains("namespace SimpleProject.CustomFolder", File.ReadAllText(artifacts["MigrationFile"] as string)); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void AddMigration_output_dir_relative_out_of_to_projectdir() - { - try - { - var artifacts = _project.Executor.AddMigration("EmptyMigration1", "../CustomFolder", "SimpleContext"); - Assert.NotNull(artifacts); - Assert.StartsWith(Path.GetFullPath(Path.Combine(_project.TargetDir, "../CustomFolder")), artifacts["MigrationFile"] as string); - AssertDefaultMigrationName(artifacts); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void AddMigration_output_dir_absolute_path_in_project() - { - try - { - var outputDir = Path.Combine(_project.TargetDir, "A", "B", "C"); - var artifacts = _project.Executor.AddMigration("EmptyMigration1", outputDir, "SimpleContext"); - Assert.NotNull(artifacts); - Assert.Equal(Path.Combine(outputDir, Path.GetFileName(artifacts["MigrationFile"] as string)), artifacts["MigrationFile"]); - Assert.Contains("namespace SimpleProject.A.B.C", File.ReadAllText(artifacts["MigrationFile"] as string)); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void AddMigration_output_dir_absolute_path_outside_project() - { - try - { - var outputDir = Path.GetTempPath(); - var artifacts = _project.Executor.AddMigration("EmptyMigration1", outputDir, "SimpleContext"); - Assert.NotNull(artifacts); - Assert.StartsWith(outputDir, artifacts["MigrationFile"] as string); - AssertDefaultMigrationName(artifacts); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void AddMigration_handles_empty_output_dir() - { - try - { - var artifacts = _project.Executor.AddMigration("EmptyMigration2", /*outputDir: */ null, "SimpleContext"); - Assert.NotNull(artifacts); - Assert.StartsWith(Path.Combine(_project.TargetDir, "Migrations"), artifacts["MigrationFile"] as string); - AssertDefaultMigrationName(artifacts); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void ScriptMigration() - { - try - { - var sql = _project.Executor.ScriptMigration(null, "InitialCreate", false, "SimpleContext"); - Assert.NotEmpty(sql); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void ScriptDbContext() - { - try - { - var sql = _project.Executor.ScriptDbContext("SimpleContext"); - Assert.NotEmpty(sql); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void GetContextTypes() - { - try - { - var contextTypes = _project.Executor.GetContextTypes(); - Assert.Single(contextTypes); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void GetMigrations() - { - try - { - var migrations = _project.Executor.GetMigrations("SimpleContext"); - Assert.Single(migrations); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - [Fact] - public void GetContextInfo_returns_connection_string() - { - try - { - var info = _project.Executor.GetContextInfo("SimpleContext"); - Assert.Equal("Microsoft.EntityFrameworkCore.SqlServer", info["ProviderName"]); - Assert.Equal(@"(localdb)\MSSQLLocalDB", info["DataSource"]); - Assert.Equal("SimpleProject.SimpleContext", info["DatabaseName"]); - Assert.Equal("None", info["Options"]); - } - catch (WrappedException ex) - { - throw new WrappedXunitException(ex); - } - } - - public class SimpleProject : IDisposable - { - private readonly TempDirectory _directory = new TempDirectory(); - - public SimpleProject() - { - var source = new BuildSource - { - TargetDir = TargetDir, - References = - { - BuildReference.ByName("System.Threading.Tasks.Extensions", true), - BuildReference.ByName("System.Interactive.Async", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Abstractions", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Design", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational", true), - BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Caching.Memory", true), - BuildReference.ByName("Microsoft.Extensions.Configuration.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection", true), - BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Logging", true), - BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions", true), - BuildReference.ByName("Microsoft.Extensions.Options", true), - BuildReference.ByName("Microsoft.Extensions.Primitives", true), - BuildReference.ByName("Remotion.Linq", true) - }, - Sources = - { - @" - using Microsoft.EntityFrameworkCore; - using Microsoft.EntityFrameworkCore.Infrastructure; - using Microsoft.EntityFrameworkCore.Migrations; - - namespace SimpleProject - { - internal class SimpleContext : DbContext - { - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer(""Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SimpleProject.SimpleContext;Integrated Security=True""); - } - - internal DbSet Simples { get; set; } - } - - internal class Simple - { - public int Id { get; set; } - } - - namespace Migrations - { - [DbContext(typeof(SimpleContext))] - [Migration(""20141010222726_InitialCreate"")] - public class InitialCreate : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - } - } - } - }" - } - }; - var build = source.Build(); - File.Copy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, build.TargetPath + ".config"); - Executor = new AppDomainOperationExecutor( - build.TargetPath, - build.TargetPath, - build.TargetDir, - build.TargetDir, - "SimpleProject", - "C#"); - } - - public string TargetDir => _directory.Path; - - internal IOperationExecutor Executor { get; } - - public void Dispose() - { - Executor.Dispose(); - _directory.Dispose(); - } - } - } -} -#elif NETCOREAPP3_0 -#else -#error target frameworks need to be updated. -#endif From 7f15ff23d9e2ef762aeef56584cf5522723abfa8 Mon Sep 17 00:00:00 2001 From: Smit Patel Date: Mon, 3 Jun 2019 16:24:13 -0700 Subject: [PATCH 4/4] Query: Rename classes which had clashes before --- .../Internal/DocumentQueryExpression.cs | 2 +- .../Query/Internal/EntityShaper.cs | 2 +- .../CosmosEntityQueryableTranslatorFactory.cs | 4 ++-- ...nMemoryEntityQueryableExpressionVisitor.cs} | 4 ++-- ...EntityQueryableExpressionVisitorFactory2.cs | 2 +- ...nMemoryEntityQueryableExpressionVisitors.cs | 2 +- .../InMemoryShapedQueryExpressionVisitor.cs | 6 +++--- ...emoryShapedQueryExpressionVisitorFactory.cs | 2 +- .../InMemoryShapedQueryOptimizerFactory.cs | 2 +- .../Query/Pipeline/Translator.cs | 2 +- ...EntityFrameworkRelationalServicesBuilder.cs | 4 ++-- .../Query/Pipeline/AsyncQueryingEnumerable.cs | 6 +++--- ...romSqlNonComposedAsyncQueryingEnumerable.cs | 6 +++--- .../FromSqlNonComposedQueryingEnumerable.cs | 6 +++--- .../Pipeline/IQuerySqlGeneratorFactory2.cs | 2 +- .../IncludeCompilingExpressionVisitor.cs | 12 ++++++------ .../Pipeline/QuerySqlGeneratorFactory2.cs | 4 ++-- .../Query/Pipeline/QueryingEnumerable.cs | 6 +++--- ...ationalEntityQueryableExpressionVisitor2.cs | 4 ++-- ...EntityQueryableExpressionVisitorFactory2.cs | 2 +- ...ationalEntityQueryableExpressionVisitors.cs | 2 +- ...tionalProjectionBindingExpressionVisitor.cs | 2 +- ...nalShapedQueryCompilingExpressionVisitor.cs | 14 +++++++------- ...ionalShapedQueryExpressionVisitorFactory.cs | 6 +++--- ...lShapedQueryOptimizingExpressionVisitors.cs | 4 ++-- ...QueryOptimizingExpressionVisitorsFactory.cs | 2 +- ...rShapedQueryOptimizingExpressionVisitors.cs | 2 +- ...QueryOptimizingExpressionVisitorsFactory.cs | 2 +- .../SqliteServiceCollectionExtensions.cs | 2 +- .../SqliteQuerySqlGeneratorFactory2.cs | 4 ++-- .../EntityFrameworkServicesBuilder.cs | 4 ++-- .../EntityQueryableExpressionVisitor2.cs | 2 +- ...EntityQueryableExpressionVisitorsFactory.cs | 2 +- ...EntityQueryableExpressionVisitorsFactory.cs | 2 +- .../IQueryCompilationContextFactory2.cs | 4 ++-- ...IQueryOptimizingExpressionVisitorFactory.cs | 2 +- .../IShapedQueryExpressionVisitorFactory.cs | 2 +- ...QueryOptimizingExpressionVisitorsFactory.cs | 2 +- .../Query/Pipeline/QueryCompilationContext2.cs | 4 ++-- .../QueryCompilationContextFactory2.cs | 8 ++++---- ...QueryMetadataExtractingExpressionVisitor.cs | 4 ++-- .../QueryOptimizingExpressionVisitor.cs | 4 ++-- .../QueryOptimizingExpressionVisitorFactory.cs | 2 +- .../Pipeline/ShapedQueryExpressionVisitor.cs | 8 ++++---- ...QueryOptimizingExpressionVisitorsFactory.cs | 2 +- src/EFCore/Storage/Database.cs | 2 +- src/EFCore/Storage/DatabaseDependencies.cs | 18 +++++++++--------- 47 files changed, 96 insertions(+), 96 deletions(-) rename src/EFCore.InMemory/Query/Pipeline/{InMemoryEntityQueryableExpressionVisitor2.cs => InMemoryEntityQueryableExpressionVisitor.cs} (79%) 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/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.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 b1df74189f1..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)); 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.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 85f47fb6919..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, @@ -56,7 +56,7 @@ 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; diff --git a/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs b/src/EFCore.Relational/Query/Pipeline/FromSqlNonComposedAsyncQueryingEnumerable.cs index ebfbc287d9c..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, @@ -57,7 +57,7 @@ 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; 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/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/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/Infrastructure/EntityFrameworkServicesBuilder.cs b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs index b7f2fe37462..130a334cec9 100644 --- a/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs +++ b/src/EFCore/Infrastructure/EntityFrameworkServicesBuilder.cs @@ -132,7 +132,7 @@ public static readonly IDictionary 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/Query/Pipeline/EntityQueryableExpressionVisitor2.cs b/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitor2.cs index e444bf74cc4..02bacc6b5af 100644 --- a/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitor2.cs +++ b/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitor2.cs @@ -8,7 +8,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { - public abstract class EntityQueryableExpressionVisitor2 : ExpressionVisitor + public abstract class EntityQueryableExpressionVisitor : ExpressionVisitor { protected override Expression VisitConstant(ConstantExpression constantExpression) => constantExpression.IsEntityQueryable() diff --git a/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitorsFactory.cs b/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitorsFactory.cs index 49adf63adb1..c205e9a7899 100644 --- a/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitorsFactory.cs +++ b/src/EFCore/Query/Pipeline/EntityQueryableExpressionVisitorsFactory.cs @@ -5,6 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public abstract class EntityQueryableTranslatorFactory : IEntityQueryableTranslatorFactory { - public abstract EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext); + public abstract EntityQueryableTranslator Create(QueryCompilationContext queryCompilationContext); } } diff --git a/src/EFCore/Query/Pipeline/IEntityQueryableExpressionVisitorsFactory.cs b/src/EFCore/Query/Pipeline/IEntityQueryableExpressionVisitorsFactory.cs index 46e9dfbcb4f..aa6e8a6ab7b 100644 --- a/src/EFCore/Query/Pipeline/IEntityQueryableExpressionVisitorsFactory.cs +++ b/src/EFCore/Query/Pipeline/IEntityQueryableExpressionVisitorsFactory.cs @@ -5,6 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public interface IEntityQueryableTranslatorFactory { - EntityQueryableTranslator Create(QueryCompilationContext2 queryCompilationContext); + EntityQueryableTranslator Create(QueryCompilationContext queryCompilationContext); } } diff --git a/src/EFCore/Query/Pipeline/IQueryCompilationContextFactory2.cs b/src/EFCore/Query/Pipeline/IQueryCompilationContextFactory2.cs index adc6610f1b6..2f3cbaf7c73 100644 --- a/src/EFCore/Query/Pipeline/IQueryCompilationContextFactory2.cs +++ b/src/EFCore/Query/Pipeline/IQueryCompilationContextFactory2.cs @@ -3,8 +3,8 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { - public interface IQueryCompilationContextFactory2 + public interface IQueryCompilationContextFactory { - QueryCompilationContext2 Create(bool async); + QueryCompilationContext Create(bool async); } } diff --git a/src/EFCore/Query/Pipeline/IQueryOptimizingExpressionVisitorFactory.cs b/src/EFCore/Query/Pipeline/IQueryOptimizingExpressionVisitorFactory.cs index 9ac84636889..d1f52fceee0 100644 --- a/src/EFCore/Query/Pipeline/IQueryOptimizingExpressionVisitorFactory.cs +++ b/src/EFCore/Query/Pipeline/IQueryOptimizingExpressionVisitorFactory.cs @@ -5,6 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public interface IQueryOptimizerFactory { - QueryOptimizer Create(QueryCompilationContext2 queryCompilationContext); + QueryOptimizer Create(QueryCompilationContext queryCompilationContext); } } diff --git a/src/EFCore/Query/Pipeline/IShapedQueryExpressionVisitorFactory.cs b/src/EFCore/Query/Pipeline/IShapedQueryExpressionVisitorFactory.cs index ad82678ac7b..bef38cb4200 100644 --- a/src/EFCore/Query/Pipeline/IShapedQueryExpressionVisitorFactory.cs +++ b/src/EFCore/Query/Pipeline/IShapedQueryExpressionVisitorFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public interface IShapedQueryCompilingExpressionVisitorFactory { - ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext2 queryCompilationContext); + ShapedQueryCompilingExpressionVisitor Create(QueryCompilationContext queryCompilationContext); } } diff --git a/src/EFCore/Query/Pipeline/IShapedQueryOptimizingExpressionVisitorsFactory.cs b/src/EFCore/Query/Pipeline/IShapedQueryOptimizingExpressionVisitorsFactory.cs index 25de8a6820e..43ead0baa10 100644 --- a/src/EFCore/Query/Pipeline/IShapedQueryOptimizingExpressionVisitorsFactory.cs +++ b/src/EFCore/Query/Pipeline/IShapedQueryOptimizingExpressionVisitorsFactory.cs @@ -5,6 +5,6 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public interface IShapedQueryOptimizerFactory { - ShapedQueryOptimizer Create(QueryCompilationContext2 queryCompilationContext); + ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext); } } diff --git a/src/EFCore/Query/Pipeline/QueryCompilationContext2.cs b/src/EFCore/Query/Pipeline/QueryCompilationContext2.cs index 568d33a53c6..80476bb1f97 100644 --- a/src/EFCore/Query/Pipeline/QueryCompilationContext2.cs +++ b/src/EFCore/Query/Pipeline/QueryCompilationContext2.cs @@ -9,7 +9,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { - public class QueryCompilationContext2 + public class QueryCompilationContext { public static readonly ParameterExpression QueryContextParameter = Expression.Parameter(typeof(QueryContext), "queryContext"); @@ -19,7 +19,7 @@ public class QueryCompilationContext2 private readonly IShapedQueryOptimizerFactory _shapedQueryOptimizerFactory; private readonly IShapedQueryCompilingExpressionVisitorFactory _shapedQueryCompilingExpressionVisitorFactory; - public QueryCompilationContext2( + public QueryCompilationContext( IModel model, IQueryOptimizerFactory queryOptimizerFactory, IEntityQueryableTranslatorFactory entityQuerableTranslatorFactory, diff --git a/src/EFCore/Query/Pipeline/QueryCompilationContextFactory2.cs b/src/EFCore/Query/Pipeline/QueryCompilationContextFactory2.cs index a1393e9e6df..59ec7325837 100644 --- a/src/EFCore/Query/Pipeline/QueryCompilationContextFactory2.cs +++ b/src/EFCore/Query/Pipeline/QueryCompilationContextFactory2.cs @@ -7,7 +7,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { - public class QueryCompilationContextFactory2 : IQueryCompilationContextFactory2 + public class QueryCompilationContextFactory : IQueryCompilationContextFactory { private readonly IModel _model; private readonly IQueryOptimizerFactory _queryOptimizerFactory; @@ -19,7 +19,7 @@ public class QueryCompilationContextFactory2 : IQueryCompilationContextFactory2 private readonly IDbContextOptions _contextOptions; private readonly IDiagnosticsLogger _logger; - public QueryCompilationContextFactory2( + public QueryCompilationContextFactory( IModel model, IQueryOptimizerFactory queryOptimizerFactory, IEntityQueryableTranslatorFactory entityQueryableTranslatorFactory, @@ -41,9 +41,9 @@ public QueryCompilationContextFactory2( _logger = logger; } - public QueryCompilationContext2 Create(bool async) + public QueryCompilationContext Create(bool async) { - var queryCompilationContext = new QueryCompilationContext2( + var queryCompilationContext = new QueryCompilationContext( _model, _queryOptimizerFactory, _entityQueryableTranslatorFactory, diff --git a/src/EFCore/Query/Pipeline/QueryMetadataExtractingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/QueryMetadataExtractingExpressionVisitor.cs index 2269c3d69fa..56210bc880c 100644 --- a/src/EFCore/Query/Pipeline/QueryMetadataExtractingExpressionVisitor.cs +++ b/src/EFCore/Query/Pipeline/QueryMetadataExtractingExpressionVisitor.cs @@ -7,9 +7,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public class QueryMetadataExtractingExpressionVisitor : ExpressionVisitor { - private readonly QueryCompilationContext2 _queryCompilationContext; + private readonly QueryCompilationContext _queryCompilationContext; - public QueryMetadataExtractingExpressionVisitor(QueryCompilationContext2 queryCompilationContext) + public QueryMetadataExtractingExpressionVisitor(QueryCompilationContext queryCompilationContext) { _queryCompilationContext = queryCompilationContext; } diff --git a/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitor.cs b/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitor.cs index 9d66f58903f..27c47c4540a 100644 --- a/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitor.cs +++ b/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitor.cs @@ -10,9 +10,9 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public class QueryOptimizer { - private readonly QueryCompilationContext2 _queryCompilationContext; + private readonly QueryCompilationContext _queryCompilationContext; - public QueryOptimizer(QueryCompilationContext2 queryCompilationContext) + public QueryOptimizer(QueryCompilationContext queryCompilationContext) { _queryCompilationContext = queryCompilationContext; } diff --git a/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitorFactory.cs b/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitorFactory.cs index 4760d1e9ef5..01a3c3465ee 100644 --- a/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitorFactory.cs +++ b/src/EFCore/Query/Pipeline/QueryOptimizingExpressionVisitorFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public class QueryOptimizerFactory : IQueryOptimizerFactory { - public QueryOptimizer Create(QueryCompilationContext2 queryCompilationContext) + public QueryOptimizer Create(QueryCompilationContext queryCompilationContext) { return new QueryOptimizer(queryCompilationContext); } diff --git a/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs b/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs index 9ebf557697f..e6d1c5f9c3a 100644 --- a/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs +++ b/src/EFCore/Query/Pipeline/ShapedQueryExpressionVisitor.cs @@ -41,7 +41,7 @@ public ShapedQueryCompilingExpressionVisitor(IEntityMaterializerSource entityMat if (async) { cancellationTokenParameter = Expression.MakeMemberAccess( - QueryCompilationContext2.QueryContextParameter, + QueryCompilationContext.QueryContextParameter, _cancellationTokenMemberInfo); } } @@ -248,7 +248,7 @@ private Expression ProcessEntityShaper(EntityShaperExpression entityShaperExpres entry, Expression.Call( Expression.MakeMemberAccess( - QueryCompilationContext2.QueryContextParameter, + QueryCompilationContext.QueryContextParameter, _stateManagerMemberInfo), _tryGetEntryMethodInfo, Expression.Constant(primaryKey), @@ -316,7 +316,7 @@ var valueBufferConstructor _materializationContextConstructor, valueBuffer, Expression.MakeMemberAccess( - QueryCompilationContext2.QueryContextParameter, + QueryCompilationContext.QueryContextParameter, _dbContextMemberInfo)))); var concreteEntityTypes = entityType.GetConcreteTypesInHierarchy().ToList(); @@ -430,7 +430,7 @@ var discriminatorValue { expressions.Add( Expression.Call( - QueryCompilationContext2.QueryContextParameter, + QueryCompilationContext.QueryContextParameter, _startTrackingMethodInfo, Expression.Constant(entityType), result, diff --git a/src/EFCore/Query/Pipeline/ShapedQueryOptimizingExpressionVisitorsFactory.cs b/src/EFCore/Query/Pipeline/ShapedQueryOptimizingExpressionVisitorsFactory.cs index f47bf630330..687404fb198 100644 --- a/src/EFCore/Query/Pipeline/ShapedQueryOptimizingExpressionVisitorsFactory.cs +++ b/src/EFCore/Query/Pipeline/ShapedQueryOptimizingExpressionVisitorsFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.EntityFrameworkCore.Query.Pipeline { public class ShapedQueryOptimizerFactory : IShapedQueryOptimizerFactory { - public virtual ShapedQueryOptimizer Create(QueryCompilationContext2 queryCompilationContext) + public virtual ShapedQueryOptimizer Create(QueryCompilationContext queryCompilationContext) { return new ShapedQueryOptimizer(); } diff --git a/src/EFCore/Storage/Database.cs b/src/EFCore/Storage/Database.cs index 749f895f445..42af355f022 100644 --- a/src/EFCore/Storage/Database.cs +++ b/src/EFCore/Storage/Database.cs @@ -69,7 +69,7 @@ public abstract Task SaveChangesAsync( public virtual Func CompileQuery2(Expression query, bool async) { - return Dependencies.QueryCompilationContextFactory2 + return Dependencies.QueryCompilationContextFactory .Create(async) .CreateQueryExecutor(query); } diff --git a/src/EFCore/Storage/DatabaseDependencies.cs b/src/EFCore/Storage/DatabaseDependencies.cs index 93c8c5f595a..033d192991a 100644 --- a/src/EFCore/Storage/DatabaseDependencies.cs +++ b/src/EFCore/Storage/DatabaseDependencies.cs @@ -47,23 +47,23 @@ public sealed class DatabaseDependencies /// the constructor at any point in this process. /// /// - /// Factory for compilation contexts to process LINQ queries. + /// Factory for compilation contexts to process LINQ queries. /// Factory for creating model data tracker. public DatabaseDependencies( - [NotNull] IQueryCompilationContextFactory2 queryCompilationContextFactory2, + [NotNull] IQueryCompilationContextFactory queryCompilationContextFactory, [NotNull] IUpdateAdapterFactory updateAdapterFactory) { - Check.NotNull(queryCompilationContextFactory2, nameof(queryCompilationContextFactory2)); + Check.NotNull(queryCompilationContextFactory, nameof(queryCompilationContextFactory)); Check.NotNull(updateAdapterFactory, nameof(updateAdapterFactory)); - QueryCompilationContextFactory2 = queryCompilationContextFactory2; + QueryCompilationContextFactory = queryCompilationContextFactory; UpdateAdapterFactory = updateAdapterFactory; } /// /// Factory for compilation contexts to process LINQ queries. /// - public IQueryCompilationContextFactory2 QueryCompilationContextFactory2 { get; } + public IQueryCompilationContextFactory QueryCompilationContextFactory { get; } /// /// Factory for creating model data tracker. @@ -73,12 +73,12 @@ public DatabaseDependencies( /// /// Clones this dependency parameter object with one service replaced. /// - /// + /// /// A replacement for the current dependency of this type. /// /// A new parameter object with the given service replaced. - public DatabaseDependencies With([NotNull] IQueryCompilationContextFactory2 queryCompilationContextFactory2) - => new DatabaseDependencies(queryCompilationContextFactory2, UpdateAdapterFactory); + public DatabaseDependencies With([NotNull] IQueryCompilationContextFactory queryCompilationContextFactory) + => new DatabaseDependencies(queryCompilationContextFactory, UpdateAdapterFactory); /// /// Clones this dependency parameter object with one service replaced. @@ -88,7 +88,7 @@ public DatabaseDependencies With([NotNull] IQueryCompilationContextFactory2 quer /// /// A new parameter object with the given service replaced. public DatabaseDependencies With([NotNull] IUpdateAdapterFactory updateAdapterFactory) - => new DatabaseDependencies(QueryCompilationContextFactory2, updateAdapterFactory); + => new DatabaseDependencies(QueryCompilationContextFactory, updateAdapterFactory); }