@@ -128,9 +128,9 @@ public virtual Expression Process(Expression expression)
128
128
selectExpression . PushdownIntoSubquery ( ) ;
129
129
}
130
130
131
- for ( int j = 0 ; j < columnsToRewrite . Count ; j ++ )
131
+ foreach ( var colr in columnsToRewrite )
132
132
{
133
- ( int ? index , OrderingExpression ? oexp , bool ascending , bool rewrite , bool referstocurouter ) = columnsToRewrite [ j ] ;
133
+ ( int ? index , OrderingExpression ? oexp , bool ascending , bool rewrite , bool referstocurouter ) = colr . Value ;
134
134
if ( index . HasValue )
135
135
{
136
136
var proj = selectExpression . Projection [ index . Value ] ;
@@ -145,20 +145,9 @@ public virtual Expression Process(Expression expression)
145
145
}
146
146
}
147
147
148
- if ( isscalarselect )
148
+ if ( isscalarselect && selectExpression . Projection . Count > 1 )
149
149
{
150
- List < ProjectionExpression > newProjections = new List < ProjectionExpression > ( ) ;
151
- for ( int j = 0 ; j < selectExpression . Projection . Count ; j ++ )
152
- {
153
- var proj = selectExpression . Projection [ j ] ;
154
- var item = columnsToRewrite . SingleOrDefault ( c => c . Value . indexcol == j ) ;
155
- if ( item . Value . indexcol == null )
156
- {
157
- newProjections . Add ( proj ) ;
158
- }
159
-
160
- }
161
-
150
+ List < ProjectionExpression > newProjections = [ selectExpression . Projection [ 0 ] ] ;
162
151
selectExpression = selectExpression . Update ( newProjections , selectExpression . Tables , selectExpression . Predicate ,
163
152
selectExpression . GroupBy , selectExpression . Having , selectExpression . Orderings ,
164
153
selectExpression . Limit , selectExpression . Offset ) ;
0 commit comments