Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Minor refactoring in shaper #28046

Merged
1 commit merged into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class FromSqlQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly IReadOnlyList<string> _columnNames;
private readonly Func<QueryContext, DbDataReader, int[], T> _shaper;
private readonly Type _contextType;
Expand All @@ -33,6 +34,7 @@ public class FromSqlQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
public FromSqlQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
RelationalCommandCache relationalCommandCache,
IReadOnlyList<ReaderColumn?>? readerColumns,
IReadOnlyList<string> columnNames,
Func<QueryContext, DbDataReader, int[], T> shaper,
Type contextType,
Expand All @@ -42,6 +44,7 @@ public FromSqlQueryingEnumerable(
{
_relationalQueryContext = relationalQueryContext;
_relationalCommandCache = relationalCommandCache;
_readerColumns = readerColumns;
_columnNames = columnNames;
_shaper = shaper;
_contextType = contextType;
Expand Down Expand Up @@ -144,6 +147,7 @@ private sealed class Enumerator : IEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly IReadOnlyList<string> _columnNames;
private readonly Func<QueryContext, DbDataReader, int[], T> _shaper;
private readonly Type _contextType;
Expand All @@ -161,6 +165,7 @@ public Enumerator(FromSqlQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_columnNames = queryingEnumerable._columnNames;
_shaper = queryingEnumerable._shaper;
_contextType = queryingEnumerable._contextType;
Expand Down Expand Up @@ -232,7 +237,7 @@ private static bool InitializeReader(Enumerator enumerator)
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorsEnabled, CommandSource.FromSqlQuery));
Expand Down Expand Up @@ -262,6 +267,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly IReadOnlyList<string> _columnNames;
private readonly Func<QueryContext, DbDataReader, int[], T> _shaper;
private readonly Type _contextType;
Expand All @@ -279,6 +285,7 @@ public AsyncEnumerator(FromSqlQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_columnNames = queryingEnumerable._columnNames;
_shaper = queryingEnumerable._shaper;
_contextType = queryingEnumerable._contextType;
Expand Down Expand Up @@ -352,7 +359,7 @@ private static async Task<bool> InitializeReaderAsync(AsyncEnumerator enumerator
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorsEnabled, CommandSource.FromSqlQuery),
Expand Down
10 changes: 0 additions & 10 deletions src/EFCore.Relational/Query/Internal/RelationalCommandCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,14 @@ public RelationalCommandCache(
IQuerySqlGeneratorFactory querySqlGeneratorFactory,
IRelationalParameterBasedSqlProcessorFactory relationalParameterBasedSqlProcessorFactory,
SelectExpression selectExpression,
IReadOnlyList<ReaderColumn?>? readerColumns,
bool useRelationalNulls)
{
_memoryCache = memoryCache;
_querySqlGeneratorFactory = querySqlGeneratorFactory;
_selectExpression = selectExpression;
ReaderColumns = readerColumns;
_relationalParameterBasedSqlProcessor = relationalParameterBasedSqlProcessorFactory.Create(useRelationalNulls);
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// 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.
/// </summary>
public virtual IReadOnlyList<ReaderColumn?>? ReaderColumns { get; }

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SingleQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, T> _shaper;
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
Expand All @@ -32,6 +33,7 @@ public class SingleQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>,
public SingleQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
RelationalCommandCache relationalCommandCache,
IReadOnlyList<ReaderColumn?>? readerColumns,
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, T> shaper,
Type contextType,
bool standAloneStateManager,
Expand All @@ -40,6 +42,7 @@ public SingleQueryingEnumerable(
{
_relationalQueryContext = relationalQueryContext;
_relationalCommandCache = relationalCommandCache;
_readerColumns = readerColumns;
_shaper = shaper;
_contextType = contextType;
_queryLogger = relationalQueryContext.QueryLogger;
Expand Down Expand Up @@ -114,6 +117,7 @@ private sealed class Enumerator : IEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, T> _shaper;
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
Expand All @@ -131,6 +135,7 @@ public Enumerator(SingleQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_shaper = queryingEnumerable._shaper;
_contextType = queryingEnumerable._contextType;
_queryLogger = queryingEnumerable._queryLogger;
Expand Down Expand Up @@ -230,7 +235,7 @@ private static bool InitializeReader(Enumerator enumerator)
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorsEnabled,
Expand Down Expand Up @@ -263,6 +268,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, T> _shaper;
private readonly Type _contextType;
private readonly IDiagnosticsLogger<DbLoggerCategory.Query> _queryLogger;
Expand All @@ -281,6 +287,7 @@ public AsyncEnumerator(SingleQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_shaper = queryingEnumerable._shaper;
_contextType = queryingEnumerable._contextType;
_queryLogger = queryingEnumerable._queryLogger;
Expand Down Expand Up @@ -383,7 +390,7 @@ private static async Task<bool> InitializeReaderAsync(AsyncEnumerator enumerator
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorsEnabled, CommandSource.LinqQuery),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class SplitQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>, I
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> _shaper;
private readonly Action<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator>? _relatedDataLoaders;
private readonly Func<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator, Task>? _relatedDataLoadersAsync;
Expand All @@ -34,6 +35,7 @@ public class SplitQueryingEnumerable<T> : IEnumerable<T>, IAsyncEnumerable<T>, I
public SplitQueryingEnumerable(
RelationalQueryContext relationalQueryContext,
RelationalCommandCache relationalCommandCache,
IReadOnlyList<ReaderColumn?>? readerColumns,
Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> shaper,
Action<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator>? relatedDataLoaders,
Func<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator, Task>? relatedDataLoadersAsync,
Expand All @@ -44,6 +46,7 @@ public SplitQueryingEnumerable(
{
_relationalQueryContext = relationalQueryContext;
_relationalCommandCache = relationalCommandCache;
_readerColumns = readerColumns;
_shaper = shaper;
_relatedDataLoaders = relatedDataLoaders;
_relatedDataLoadersAsync = relatedDataLoadersAsync;
Expand Down Expand Up @@ -122,6 +125,7 @@ private sealed class Enumerator : IEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> _shaper;
private readonly Action<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator>? _relatedDataLoaders;
private readonly Type _contextType;
Expand All @@ -140,6 +144,7 @@ public Enumerator(SplitQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_shaper = queryingEnumerable._shaper;
_relatedDataLoaders = queryingEnumerable._relatedDataLoaders;
_contextType = queryingEnumerable._contextType;
Expand Down Expand Up @@ -226,7 +231,7 @@ private static bool InitializeReader(Enumerator enumerator)
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorsEnabled,
Expand Down Expand Up @@ -271,6 +276,7 @@ private sealed class AsyncEnumerator : IAsyncEnumerator<T>
{
private readonly RelationalQueryContext _relationalQueryContext;
private readonly RelationalCommandCache _relationalCommandCache;
private readonly IReadOnlyList<ReaderColumn?>? _readerColumns;
private readonly Func<QueryContext, DbDataReader, ResultContext, SplitQueryResultCoordinator, T> _shaper;
private readonly Func<QueryContext, IExecutionStrategy, SplitQueryResultCoordinator, Task>? _relatedDataLoaders;
private readonly Type _contextType;
Expand All @@ -290,6 +296,7 @@ public AsyncEnumerator(SplitQueryingEnumerable<T> queryingEnumerable)
{
_relationalQueryContext = queryingEnumerable._relationalQueryContext;
_relationalCommandCache = queryingEnumerable._relationalCommandCache;
_readerColumns = queryingEnumerable._readerColumns;
_shaper = queryingEnumerable._shaper;
_relatedDataLoaders = queryingEnumerable._relatedDataLoadersAsync;
_contextType = queryingEnumerable._contextType;
Expand Down Expand Up @@ -379,7 +386,7 @@ private static async Task<bool> InitializeReaderAsync(AsyncEnumerator enumerator
new RelationalCommandParameterObject(
enumerator._relationalQueryContext.Connection,
enumerator._relationalQueryContext.ParameterValues,
enumerator._relationalCommandCache.ReaderColumns,
enumerator._readerColumns,
enumerator._relationalQueryContext.Context,
enumerator._relationalQueryContext.CommandLogger,
enumerator._detailedErrorEnabled, CommandSource.LinqQuery),
Expand Down
Loading