@@ -1232,64 +1232,73 @@ Expression CopyProjectionToOuter(SelectExpression innerSelectExpression, Express
1232
1232
{
1233
1233
var constantValue = ( ( ConstantExpression ) innerSelectExpression . _clientProjections [ j ] ) . Value ! ;
1234
1234
ConstantExpression remappedConstant ;
1235
- if ( constantValue is Dictionary < IProperty , int > entityDictionary )
1235
+ switch ( ( ( ConstantExpression ) innerSelectExpression . _clientProjections [ j ] ) . Value ! )
1236
1236
{
1237
- var newDictionary = new Dictionary < IProperty , int > ( entityDictionary . Count ) ;
1238
- foreach ( var ( property , value ) in entityDictionary )
1237
+ case Dictionary < IProperty , int > entityDictionary :
1239
1238
{
1240
- newDictionary [ property ] = projectionIndexMap [ value ] ;
1241
- }
1242
-
1243
- remappedConstant = Constant ( newDictionary ) ;
1244
- }
1245
- else if ( constantValue is JsonProjectionInfo jsonProjectionInfo )
1246
- {
1247
- var newKeyAccessInfo = new List < ( IProperty ? , int ? , int ? ) > ( ) ;
1248
- foreach ( var ( keyProperty , constantKeyValue , keyProjectionIndex ) in jsonProjectionInfo . KeyAccessInfo )
1249
- {
1250
- newKeyAccessInfo . Add (
1251
- ( keyProperty , constantKeyValue ,
1252
- keyProjectionIndex != null ? projectionIndexMap [ keyProjectionIndex . Value ] : null ) ) ;
1253
- }
1239
+ var newDictionary = new Dictionary < IProperty , int > ( entityDictionary . Count ) ;
1240
+ foreach ( var ( property , value ) in entityDictionary )
1241
+ {
1242
+ newDictionary [ property ] = projectionIndexMap [ value ] ;
1243
+ }
1254
1244
1255
- remappedConstant = Constant (
1256
- new JsonProjectionInfo (
1257
- projectionIndexMap [ jsonProjectionInfo . JsonColumnIndex ] ,
1258
- newKeyAccessInfo ) ) ;
1259
- }
1260
- else if ( constantValue is QueryableJsonProjectionInfo queryableJsonProjectionInfo )
1261
- {
1262
- var newPropertyIndexMap = new Dictionary < IProperty , int > ( queryableJsonProjectionInfo . PropertyIndexMap . Count ) ;
1263
- foreach ( var ( property , value ) in queryableJsonProjectionInfo . PropertyIndexMap )
1264
- {
1265
- newPropertyIndexMap [ property ] = projectionIndexMap [ value ] ;
1245
+ remappedConstant = Constant ( newDictionary ) ;
1246
+ break ;
1266
1247
}
1267
1248
1268
- var newChildrenProjectionInfo = new List < ( JsonProjectionInfo , INavigation ) > ( ) ;
1269
- foreach ( var childProjectionInfo in queryableJsonProjectionInfo . ChildrenProjectionInfo )
1249
+ case JsonProjectionInfo jsonProjectionInfo :
1270
1250
{
1271
1251
var newKeyAccessInfo = new List < ( IProperty ? , int ? , int ? ) > ( ) ;
1272
- foreach ( var ( keyProperty , constantKeyValue , keyProjectionIndex ) in childProjectionInfo . JsonProjectionInfo
1273
- . KeyAccessInfo )
1252
+ foreach ( var ( keyProperty , constantKeyValue , keyProjectionIndex ) in jsonProjectionInfo . KeyAccessInfo )
1274
1253
{
1275
1254
newKeyAccessInfo . Add (
1276
1255
( keyProperty , constantKeyValue ,
1277
1256
keyProjectionIndex != null ? projectionIndexMap [ keyProjectionIndex . Value ] : null ) ) ;
1278
1257
}
1279
1258
1280
- newChildrenProjectionInfo . Add (
1281
- ( new JsonProjectionInfo (
1282
- projectionIndexMap [ childProjectionInfo . JsonProjectionInfo . JsonColumnIndex ] ,
1283
- newKeyAccessInfo ) ,
1284
- childProjectionInfo . Navigation ) ) ;
1259
+ remappedConstant = Constant (
1260
+ new JsonProjectionInfo (
1261
+ projectionIndexMap [ jsonProjectionInfo . JsonColumnIndex ] ,
1262
+ newKeyAccessInfo ) ) ;
1263
+ break ;
1285
1264
}
1286
1265
1287
- remappedConstant = Constant (
1288
- new QueryableJsonProjectionInfo ( newPropertyIndexMap , newChildrenProjectionInfo ) ) ;
1289
- }
1290
- else
1291
- {
1292
- remappedConstant = Constant ( projectionIndexMap [ ( int ) constantValue ] ) ;
1266
+ case QueryableJsonProjectionInfo queryableJsonProjectionInfo :
1267
+ {
1268
+ var newPropertyIndexMap = new Dictionary < IProperty , int > ( queryableJsonProjectionInfo . PropertyIndexMap . Count ) ;
1269
+ foreach ( var ( property , value ) in queryableJsonProjectionInfo . PropertyIndexMap )
1270
+ {
1271
+ newPropertyIndexMap [ property ] = projectionIndexMap [ value ] ;
1272
+ }
1273
+
1274
+ var newChildrenProjectionInfo = new List < ( JsonProjectionInfo , INavigation ) > ( ) ;
1275
+ foreach ( var childProjectionInfo in queryableJsonProjectionInfo . ChildrenProjectionInfo )
1276
+ {
1277
+ var newKeyAccessInfo = new List < ( IProperty ? , int ? , int ? ) > ( ) ;
1278
+ foreach ( var ( keyProperty , constantKeyValue , keyProjectionIndex ) in childProjectionInfo . JsonProjectionInfo
1279
+ . KeyAccessInfo )
1280
+ {
1281
+ newKeyAccessInfo . Add (
1282
+ ( keyProperty , constantKeyValue ,
1283
+ keyProjectionIndex != null ? projectionIndexMap [ keyProjectionIndex . Value ] : null ) ) ;
1284
+ }
1285
+
1286
+ newChildrenProjectionInfo . Add (
1287
+ ( new JsonProjectionInfo (
1288
+ projectionIndexMap [ childProjectionInfo . JsonProjectionInfo . JsonColumnIndex ] ,
1289
+ newKeyAccessInfo ) ,
1290
+ childProjectionInfo . Navigation ) ) ;
1291
+ }
1292
+
1293
+ remappedConstant = Constant (
1294
+ new QueryableJsonProjectionInfo ( newPropertyIndexMap , newChildrenProjectionInfo ) ) ;
1295
+
1296
+ break ;
1297
+ }
1298
+
1299
+ default :
1300
+ remappedConstant = Constant ( projectionIndexMap [ ( int ) constantValue ] ) ;
1301
+ break ;
1293
1302
}
1294
1303
1295
1304
newClientProjections . Add ( remappedConstant ) ;
@@ -4031,26 +4040,26 @@ private static ColumnExpression CreateColumnExpression(
4031
4040
string tableAlias ,
4032
4041
bool nullable )
4033
4042
=> new (
4034
- column ,
4043
+ column . Name ,
4035
4044
tableAlias ,
4045
+ column ,
4036
4046
property . ClrType . UnwrapNullableType ( ) ,
4037
4047
column . PropertyMappings . First ( m => m . Property == property ) . TypeMapping ,
4038
- nullable ) ;
4048
+ nullable || column . IsNullable ) ;
4039
4049
4040
4050
private static ColumnExpression CreateColumnExpression ( ProjectionExpression subqueryProjection , string tableAlias )
4041
- => subqueryProjection . Expression is ColumnExpression { Column : IColumnBase column , TypeMapping : RelationalTypeMapping typeMapping } columnExpression
4042
- ? new ( column , tableAlias , columnExpression . Type , typeMapping , columnExpression . IsNullable )
4043
- : new (
4044
- subqueryProjection . Alias ,
4045
- tableAlias ,
4046
- subqueryProjection . Type ,
4047
- subqueryProjection . Expression . TypeMapping ! ,
4048
- subqueryProjection . Expression switch
4049
- {
4050
- ColumnExpression c => c . IsNullable ,
4051
- SqlConstantExpression c => c . Value is null ,
4052
- _ => true
4053
- } ) ;
4051
+ => new (
4052
+ subqueryProjection . Alias ,
4053
+ tableAlias ,
4054
+ column : subqueryProjection . Expression is ColumnExpression { Column : IColumnBase column } ? column : null ,
4055
+ subqueryProjection . Type ,
4056
+ subqueryProjection . Expression . TypeMapping ! ,
4057
+ subqueryProjection . Expression switch
4058
+ {
4059
+ ColumnExpression c => c . IsNullable ,
4060
+ SqlConstantExpression c => c . Value is null ,
4061
+ _ => true
4062
+ } ) ;
4054
4063
4055
4064
private ColumnExpression GenerateOuterColumn (
4056
4065
string tableAlias ,
0 commit comments