@@ -293,6 +293,7 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
293293 LinqParameterContainer . Parameterize ( typeof ( string ) , _modelID ) :
294294 Expression . Constant ( _modelID ) ;
295295 wrapperTypeMemberAssignments . Add ( Expression . Bind ( wrapperProperty , wrapperPropertyValueExpression ) ) ;
296+
296297 if ( IsSelectAll ( selectExpandClause ) )
297298 {
298299 // Initialize property 'Instance' on the wrapper class
@@ -345,11 +346,16 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
345346 }
346347 }
347348 }
349+ if ( isInstancePropertySet )
350+ {
351+ Type wrapperGenericType = GetWrapperGenericType ( isInstancePropertySet , isTypeNamePropertySet , isContainerPropertySet ) ;
352+ wrapperType = wrapperGenericType . MakeGenericType ( elementType ) ;
353+ return Expression . MemberInit ( Expression . New ( wrapperType ) , wrapperTypeMemberAssignments ) ;
354+ }
355+ ConstructorInfo constructorWithInstanse = wrapperType . GetConstructors ( ) . Single ( c => c . GetParameters ( ) . Length == 1 ) ;
356+ return Expression . MemberInit ( Expression . New ( constructorWithInstanse , source ) , wrapperTypeMemberAssignments ) ;
348357
349- Type wrapperGenericType = GetWrapperGenericType ( isInstancePropertySet , isTypeNamePropertySet , isContainerPropertySet ) ;
350- wrapperType = wrapperGenericType . MakeGenericType ( elementType ) ;
351358
352- return Expression . MemberInit ( Expression . New ( wrapperType ) , wrapperTypeMemberAssignments ) ;
353359 }
354360
355361 /// <summary>
@@ -1243,54 +1249,18 @@ property selection combination possible. */
12431249
12441250 private class SelectAllAndExpand < TEntity > : SelectExpandWrapper < TEntity >
12451251 {
1246- public SelectAllAndExpand ( TEntity entity ) : base ( entity )
1247- {
1248-
1249- }
1250-
1251- public SelectAllAndExpand ( )
1252- {
1253-
1254- }
12551252 }
12561253
12571254 private class SelectAll < TEntity > : SelectExpandWrapper < TEntity >
12581255 {
1259- public SelectAll ( TEntity entity ) : base ( entity )
1260- {
1261-
1262- }
1263-
1264- public SelectAll ( )
1265- {
1266-
1267- }
12681256 }
12691257
12701258 private class SelectSomeAndInheritance < TEntity > : SelectExpandWrapper < TEntity >
12711259 {
1272- public SelectSomeAndInheritance ( TEntity entity ) : base ( entity )
1273- {
1274-
1275- }
1276-
1277- public SelectSomeAndInheritance ( )
1278- {
1279-
1280- }
12811260 }
12821261
12831262 private class SelectSome < TEntity > : SelectAllAndExpand < TEntity >
12841263 {
1285- public SelectSome ( TEntity entity ) : base ( entity )
1286- {
1287-
1288- }
1289-
1290- public SelectSome ( )
1291- {
1292-
1293- }
12941264 }
12951265 }
12961266}
0 commit comments