@@ -27,6 +27,9 @@ public sealed partial class ShaperProcessingExpressionVisitor : ExpressionVisito
2727 private static readonly bool UseOldBehavior35212 =
2828 AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue35212" , out var enabled35212 ) && enabled35212 ;
2929
30+ private static readonly bool UseOldBehavior36464 =
31+ AppContext . TryGetSwitch ( "Microsoft.EntityFrameworkCore.Issue36464" , out var enabled36464 ) && enabled36464 ;
32+
3033 /// <summary>
3134 /// Reading database values
3235 /// </summary>
@@ -103,6 +106,9 @@ private static readonly PropertyInfo Utf8JsonReaderTokenTypeProperty
103106 private static readonly MethodInfo PropertyGetTypeMappingMethod =
104107 typeof ( IReadOnlyProperty ) . GetMethod ( nameof ( IReadOnlyProperty . GetTypeMapping ) , [ ] ) ! ;
105108
109+ private static readonly PropertyInfo QueryContextQueryLoggerProperty =
110+ typeof ( QueryContext ) . GetProperty ( nameof ( QueryContext . QueryLogger ) ) ! ;
111+
106112 private readonly RelationalShapedQueryCompilingExpressionVisitor _parentVisitor ;
107113 private readonly ISet < string > ? _tags ;
108114 private readonly bool _isTracking ;
@@ -1928,11 +1934,13 @@ protected override Expression VisitSwitch(SwitchExpression switchExpression)
19281934 New (
19291935 JsonReaderManagerConstructor ,
19301936 jsonReaderDataParameter ,
1931- liftableConstantFactory . CreateLiftableConstant (
1932- queryLogger ,
1933- static c => c . Dependencies . QueryLogger ,
1934- "queryLogger" ,
1935- typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) ) ) ) ,
1937+ UseOldBehavior36464
1938+ ? liftableConstantFactory . CreateLiftableConstant (
1939+ queryLogger ,
1940+ static c => c . Dependencies . QueryLogger ,
1941+ "queryLogger" ,
1942+ typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) )
1943+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ,
19361944 // tokenType = jsonReaderManager.CurrentReader.TokenType
19371945 Assign (
19381946 tokenTypeVariable ,
@@ -2113,11 +2121,13 @@ void ProcessFixup(IDictionary<string, LambdaExpression> fixupMap)
21132121 New (
21142122 JsonReaderManagerConstructor ,
21152123 jsonReaderDataParameter ,
2116- liftableConstantFactory . CreateLiftableConstant (
2117- queryLogger ,
2118- static c => c . Dependencies . QueryLogger ,
2119- "queryLogger" ,
2120- typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) ) ) ) ;
2124+ UseOldBehavior36464
2125+ ? liftableConstantFactory . CreateLiftableConstant (
2126+ queryLogger ,
2127+ static c => c . Dependencies . QueryLogger ,
2128+ "queryLogger" ,
2129+ typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) )
2130+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ;
21212131
21222132 readExpressions . Add (
21232133 Block (
@@ -2472,11 +2482,13 @@ private bool IsPropertyAssignment(
24722482 New (
24732483 JsonReaderManagerConstructor ,
24742484 jsonReaderDataVariable ,
2475- _parentVisitor . Dependencies . LiftableConstantFactory . CreateLiftableConstant (
2476- _queryLogger ,
2477- static c => c . Dependencies . QueryLogger ,
2478- "queryLogger" ,
2479- typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) ) ) ) ,
2485+ UseOldBehavior36464
2486+ ? _parentVisitor . Dependencies . LiftableConstantFactory . CreateLiftableConstant (
2487+ _queryLogger ,
2488+ static c => c . Dependencies . QueryLogger ,
2489+ "queryLogger" ,
2490+ typeof ( IDiagnosticsLogger < DbLoggerCategory . Query > ) )
2491+ : MakeMemberAccess ( QueryCompilationContext . QueryContextParameter , QueryContextQueryLoggerProperty ) ) ) ,
24802492 Call ( jsonReaderManagerVariable , Utf8JsonReaderManagerMoveNextMethod ) ,
24812493 Call ( jsonReaderManagerVariable , Utf8JsonReaderManagerCaptureStateMethod ) ) ) ;
24822494
@@ -2849,7 +2861,7 @@ Expression valueExpression
28492861 // UPDATE: instead of guessing the type mapping in case where we don't have IProperty and converter uses non-literal constant,
28502862 // we just revert to the pre-AOT behavior, i.e. we still use converter.ConvertFromProviderExpression
28512863 // this will not work for precompiled query (which realistically was already broken for this scenario - type mapping we "guess"
2852- // is pretty much always wrong), but regular case (not pre-compiled) will continue to work.
2864+ // is pretty much always wrong), but regular case (not pre-compiled) will continue to work.
28532865 if ( property != null )
28542866 {
28552867 var typeMappingExpression = Call (
0 commit comments