@@ -58,6 +58,7 @@ private static readonly PropertyInfo QueryContextContextPropertyInfo
5858
5959 private readonly Dictionary < string , object ? > _parameters = new ( ) ;
6060
61+
6162 /// <summary>
6263 /// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
6364 /// the same compatibility standards as public APIs. It may be changed or removed without notice in
@@ -1082,11 +1083,18 @@ private Expression ProcessExecuteUpdate(NavigationExpansionExpression source, Me
10821083
10831084 // Apply any pending selector before processing the ExecuteUpdate setters; this adds a Select() (if necessary) before
10841085 // ExecuteUpdate, to avoid the pending selector flowing into each setter lambda and making it more complicated.
1086+ // However, only do this when the pending selector produces entity/structural type references (i.e. the snapshot is not just
1087+ // a DefaultExpression). When the pending selector projects only scalar values (e.g. select new { p.Used, n.Qty }),
1088+ // applying it would lose the connection between the projected scalar and the original entity property, breaking
1089+ // ExecuteUpdate's property selector recognition (#37771).
10851090 var newStructure = SnapshotExpression ( source . PendingSelector ) ;
1086- var queryable = Reduce ( source ) ;
1087- var navigationTree = new NavigationTreeExpression ( newStructure ) ;
1088- var parameterName = source . CurrentParameter . Name ?? GetParameterName ( "e" ) ;
1089- source = new NavigationExpansionExpression ( queryable , navigationTree , navigationTree , parameterName ) ;
1091+ if ( newStructure is not DefaultExpression )
1092+ {
1093+ var queryable = Reduce ( source ) ;
1094+ var navigationTree = new NavigationTreeExpression ( newStructure ) ;
1095+ var parameterName = source . CurrentParameter . Name ?? GetParameterName ( "e" ) ;
1096+ source = new NavigationExpansionExpression ( queryable , navigationTree , navigationTree , parameterName ) ;
1097+ }
10901098
10911099 NewArrayExpression settersArray ;
10921100 switch ( setters )
0 commit comments