@@ -293,6 +293,7 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
293
293
LinqParameterContainer . Parameterize ( typeof ( string ) , _modelID ) :
294
294
Expression . Constant ( _modelID ) ;
295
295
wrapperTypeMemberAssignments . Add ( Expression . Bind ( wrapperProperty , wrapperPropertyValueExpression ) ) ;
296
+
296
297
if ( IsSelectAll ( selectExpandClause ) )
297
298
{
298
299
// Initialize property 'Instance' on the wrapper class
@@ -345,11 +346,16 @@ internal Expression ProjectElement(Expression source, SelectExpandClause selectE
345
346
}
346
347
}
347
348
}
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 ) ;
348
357
349
- Type wrapperGenericType = GetWrapperGenericType ( isInstancePropertySet , isTypeNamePropertySet , isContainerPropertySet ) ;
350
- wrapperType = wrapperGenericType . MakeGenericType ( elementType ) ;
351
358
352
- return Expression . MemberInit ( Expression . New ( wrapperType ) , wrapperTypeMemberAssignments ) ;
353
359
}
354
360
355
361
/// <summary>
@@ -1243,54 +1249,18 @@ property selection combination possible. */
1243
1249
1244
1250
private class SelectAllAndExpand < TEntity > : SelectExpandWrapper < TEntity >
1245
1251
{
1246
- public SelectAllAndExpand ( TEntity entity ) : base ( entity )
1247
- {
1248
-
1249
- }
1250
-
1251
- public SelectAllAndExpand ( )
1252
- {
1253
-
1254
- }
1255
1252
}
1256
1253
1257
1254
private class SelectAll < TEntity > : SelectExpandWrapper < TEntity >
1258
1255
{
1259
- public SelectAll ( TEntity entity ) : base ( entity )
1260
- {
1261
-
1262
- }
1263
-
1264
- public SelectAll ( )
1265
- {
1266
-
1267
- }
1268
1256
}
1269
1257
1270
1258
private class SelectSomeAndInheritance < TEntity > : SelectExpandWrapper < TEntity >
1271
1259
{
1272
- public SelectSomeAndInheritance ( TEntity entity ) : base ( entity )
1273
- {
1274
-
1275
- }
1276
-
1277
- public SelectSomeAndInheritance ( )
1278
- {
1279
-
1280
- }
1281
1260
}
1282
1261
1283
1262
private class SelectSome < TEntity > : SelectAllAndExpand < TEntity >
1284
1263
{
1285
- public SelectSome ( TEntity entity ) : base ( entity )
1286
- {
1287
-
1288
- }
1289
-
1290
- public SelectSome ( )
1291
- {
1292
-
1293
- }
1294
1264
}
1295
1265
}
1296
1266
}
0 commit comments