@@ -152,10 +152,15 @@ private Materializer
152152 return new Materializer ( projectorExpression . CachingCompile ( ) ) ;
153153 }
154154
155- private List < Expression > VisitNewExpressionArguments ( NewExpression n )
155+ private Expression [ ] VisitNewExpressionArguments ( NewExpression n , out ParameterInfo [ ] constructorParameters )
156156 {
157- var arguments = new List < Expression > ( ) ;
157+ constructorParameters = n . GetConstructorParameters ( ) ;
158+ if ( n . Arguments . Count == 0 ) {
159+ return Array . Empty < Expression > ( ) ;
160+ }
161+ var arguments = new Expression [ n . Arguments . Count ] ;
158162 var origArguments = n . Arguments ;
163+
159164 for ( int i = 0 , count = origArguments . Count ; i < count ; i ++ ) {
160165 var argument = origArguments [ i ] ;
161166
@@ -169,16 +174,14 @@ private List<Expression> VisitNewExpressionArguments(NewExpression n)
169174 body = body . IsProjection ( )
170175 ? BuildSubqueryResult ( ( ProjectionExpression ) body , argument . Type )
171176 : ProcessProjectionElement ( body ) ;
172- arguments . Add ( body ) ;
173- }
174- var constructorParameters = n . GetConstructorParameters ( ) ;
175- for ( int i = 0 ; i < arguments . Count ; i ++ ) {
176- if ( arguments [ i ] . Type != constructorParameters [ i ] . ParameterType )
177- arguments [ i ] = Expression . Convert ( arguments [ i ] , constructorParameters [ i ] . ParameterType ) ;
177+ arguments [ i ] = body . Type != constructorParameters [ i ] . ParameterType
178+ ? Expression . Convert ( body , constructorParameters [ i ] . ParameterType )
179+ : body ;
178180 }
179181 return arguments ;
180182 }
181183
184+
182185 private void VisitNewExpressionArgumentsSkipResults ( NewExpression n )
183186 {
184187 var origArguments = n . Arguments ;
0 commit comments