@@ -19,6 +19,9 @@ private sealed partial class ShaperProcessingExpressionVisitor : ExpressionVisit
1919 public static readonly bool UseOldBehavior32310 =
2020 AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue32310" , out var enabled32310 ) && enabled32310 ;
2121
22+ private static readonly bool UseOldBehavior36464 =
23+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue36464" , out var enabled36464 ) && enabled36464 ;
24+
2225 /// <summary>
2326 /// Reading database values
2427 /// </summary>
@@ -80,6 +83,9 @@ private static readonly MethodInfo Utf8JsonReaderGetStringMethod
8083 private static readonly MethodInfo EnumParseMethodInfo
8184 = typeof ( Enum ) . GetMethod ( nameof ( Enum . Parse ) , new [ ] { typeof ( Type ) , typeof ( string ) } ) ! ;
8285
86+ private static readonly PropertyInfo QueryContextQueryLoggerProperty =
87+ typeof ( QueryContext ) . GetProperty ( nameof ( QueryContext . QueryLogger ) ) ! ;
88+
8389 private readonly RelationalShapedQueryCompilingExpressionVisitor _parentVisitor ;
8490 private readonly ISet < string > ? _tags ;
8591 private readonly bool _isTracking ;
@@ -1644,7 +1650,9 @@ protected override Expression VisitSwitch(SwitchExpression switchExpression)
16441650 New (
16451651 JsonReaderManagerConstructor ,
16461652 _jsonReaderDataParameter ,
1647- Constant ( _queryLogger ) ) ) ,
1653+ UseOldBehavior36464
1654+ ? Constant ( _queryLogger )
1655+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ,
16481656 // tokenType = jsonReaderManager.CurrentReader.TokenType
16491657 Assign (
16501658 tokenTypeVariable ,
@@ -1807,7 +1815,13 @@ void ProcessFixup(IDictionary<string, LambdaExpression> fixupMap)
18071815 var captureState = Call ( managerVariable , Utf8JsonReaderManagerCaptureStateMethod ) ;
18081816 var assignment = Assign ( propertyVariable , innerShaperMapElement . Value ) ;
18091817 var managerRecreation = Assign (
1810- managerVariable , New ( JsonReaderManagerConstructor , _jsonReaderDataParameter , Constant ( _queryLogger ) ) ) ;
1818+ managerVariable ,
1819+ New (
1820+ JsonReaderManagerConstructor ,
1821+ _jsonReaderDataParameter ,
1822+ UseOldBehavior36464
1823+ ? Constant ( _queryLogger )
1824+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ;
18111825
18121826 readExpressions . Add (
18131827 Block (
@@ -2170,7 +2184,13 @@ private static IList<T> PopulateList<T>(IList<T> buffer, IList<T> target)
21702184 Default ( typeof ( JsonReaderData ) ) ) ,
21712185 Block (
21722186 Assign (
2173- jsonReaderManagerVariable , New ( JsonReaderManagerConstructor , jsonReaderDataVariable , Constant ( _queryLogger ) ) ) ,
2187+ jsonReaderManagerVariable ,
2188+ New (
2189+ JsonReaderManagerConstructor ,
2190+ jsonReaderDataVariable ,
2191+ UseOldBehavior36464
2192+ ? Constant ( _queryLogger )
2193+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ,
21742194 Call ( jsonReaderManagerVariable , Utf8JsonReaderManagerMoveNextMethod ) ,
21752195 Call ( jsonReaderManagerVariable , Utf8JsonReaderManagerCaptureStateMethod ) ) ) ;
21762196
0 commit comments