Skip to content
Merged
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 @@ -19,6 +19,9 @@ private sealed partial class ShaperProcessingExpressionVisitor : ExpressionVisit
public static readonly bool UseOldBehavior32310 =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue32310", out var enabled32310) && enabled32310;

private static readonly bool UseOldBehavior36464 =
AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue36464", out var enabled36464) && enabled36464;

/// <summary>
/// Reading database values
/// </summary>
Expand Down Expand Up @@ -80,6 +83,9 @@ private static readonly MethodInfo Utf8JsonReaderGetStringMethod
private static readonly MethodInfo EnumParseMethodInfo
= typeof(Enum).GetMethod(nameof(Enum.Parse), new[] { typeof(Type), typeof(string) })!;

private static readonly PropertyInfo QueryContextQueryLoggerProperty =
typeof(QueryContext).GetProperty(nameof(QueryContext.QueryLogger))!;

private readonly RelationalShapedQueryCompilingExpressionVisitor _parentVisitor;
private readonly ISet<string>? _tags;
private readonly bool _isTracking;
Expand Down Expand Up @@ -1644,7 +1650,9 @@ protected override Expression VisitSwitch(SwitchExpression switchExpression)
New(
JsonReaderManagerConstructor,
_jsonReaderDataParameter,
Constant(_queryLogger))),
UseOldBehavior36464
? Constant(_queryLogger)
: MakeMemberAccess(QueryCompilationContext.QueryContextParameter, QueryContextQueryLoggerProperty))),
// tokenType = jsonReaderManager.CurrentReader.TokenType
Assign(
tokenTypeVariable,
Expand Down Expand Up @@ -1807,7 +1815,13 @@ void ProcessFixup(IDictionary<string, LambdaExpression> fixupMap)
var captureState = Call(managerVariable, Utf8JsonReaderManagerCaptureStateMethod);
var assignment = Assign(propertyVariable, innerShaperMapElement.Value);
var managerRecreation = Assign(
managerVariable, New(JsonReaderManagerConstructor, _jsonReaderDataParameter, Constant(_queryLogger)));
managerVariable,
New(
JsonReaderManagerConstructor,
_jsonReaderDataParameter,
UseOldBehavior36464
? Constant(_queryLogger)
: MakeMemberAccess(QueryCompilationContext.QueryContextParameter, QueryContextQueryLoggerProperty)));

readExpressions.Add(
Block(
Expand Down Expand Up @@ -2170,7 +2184,13 @@ private static IList<T> PopulateList<T>(IList<T> buffer, IList<T> target)
Default(typeof(JsonReaderData))),
Block(
Assign(
jsonReaderManagerVariable, New(JsonReaderManagerConstructor, jsonReaderDataVariable, Constant(_queryLogger))),
jsonReaderManagerVariable,
New(
JsonReaderManagerConstructor,
jsonReaderDataVariable,
UseOldBehavior36464
? Constant(_queryLogger)
: MakeMemberAccess(QueryCompilationContext.QueryContextParameter, QueryContextQueryLoggerProperty))),
Call(jsonReaderManagerVariable, Utf8JsonReaderManagerMoveNextMethod),
Call(jsonReaderManagerVariable, Utf8JsonReaderManagerCaptureStateMethod)));

Expand Down
Loading