@@ -16,6 +16,11 @@ namespace Xtensive.Orm
16
16
/// </summary>
17
17
public static partial class QueryableExtensions
18
18
{
19
+ private static class ParameterTraits < TSource >
20
+ {
21
+ public static readonly ParameterExpression [ ] ItemParam = [ Expression . Parameter ( typeof ( TSource ) , "item" ) ] ;
22
+ }
23
+
19
24
private static readonly object BoxedZero = 0 ;
20
25
21
26
/// <summary>
@@ -1399,7 +1404,7 @@ public static async Task<Dictionary<TKey, TSource>> ToDictionaryAsync<TKey, TSou
1399
1404
Expression < Func < TSource , TKey > > keySelector , CancellationToken cancellationToken = default )
1400
1405
{
1401
1406
var tupleFactoryMethod = TupleCreateMethod . CachedMakeGenericMethod ( typeof ( TKey ) , typeof ( TSource ) ) ;
1402
- var itemParam = new [ ] { Expression . Parameter ( typeof ( TSource ) , "item" ) } ;
1407
+ var itemParam = ParameterTraits < TSource > . ItemParam ;
1403
1408
var body = Expression . Call ( null , tupleFactoryMethod ,
1404
1409
ExpressionReplacer . ReplaceAll ( keySelector . Body , keySelector . Parameters , itemParam ) ,
1405
1410
itemParam [ 0 ] ) ;
@@ -1441,7 +1446,7 @@ public static async Task<Dictionary<TKey, TValue>> ToDictionaryAsync<TKey, TValu
1441
1446
CancellationToken cancellationToken = default )
1442
1447
{
1443
1448
var tupleFactoryMethod = TupleCreateMethod . CachedMakeGenericMethod ( typeof ( TKey ) , typeof ( TValue ) ) ;
1444
- var itemParam = new [ ] { Expression . Parameter ( typeof ( TSource ) , "item" ) } ;
1449
+ var itemParam = ParameterTraits < TSource > . ItemParam ;
1445
1450
var body = Expression . Call ( null , tupleFactoryMethod ,
1446
1451
ExpressionReplacer . ReplaceAll ( keySelector . Body , keySelector . Parameters , itemParam ) ,
1447
1452
ExpressionReplacer . ReplaceAll ( valueSelector . Body , valueSelector . Parameters , itemParam ) ) ;
@@ -1506,7 +1511,7 @@ public static async Task<ILookup<TKey, TSource>> ToLookupAsync<TKey, TSource>(th
1506
1511
Expression < Func < TSource , TKey > > keySelector , CancellationToken cancellationToken = default )
1507
1512
{
1508
1513
var tupleFactoryMethod = TupleCreateMethod . CachedMakeGenericMethod ( typeof ( TKey ) , typeof ( TSource ) ) ;
1509
- var itemParam = new [ ] { Expression . Parameter ( typeof ( TSource ) , "item" ) } ;
1514
+ var itemParam = ParameterTraits < TSource > . ItemParam ;
1510
1515
var body = Expression . Call ( null , tupleFactoryMethod ,
1511
1516
ExpressionReplacer . ReplaceAll ( keySelector . Body , keySelector . Parameters , itemParam ) ,
1512
1517
itemParam [ 0 ] ) ;
@@ -1543,7 +1548,7 @@ public static async Task<ILookup<TKey, TValue>> ToLookupAsync<TKey, TValue, TSou
1543
1548
CancellationToken cancellationToken = default )
1544
1549
{
1545
1550
var tupleFactoryMethod = TupleCreateMethod . CachedMakeGenericMethod ( typeof ( TKey ) , typeof ( TValue ) ) ;
1546
- var itemParam = new [ ] { Expression . Parameter ( typeof ( TSource ) , "item" ) } ;
1551
+ var itemParam = ParameterTraits < TSource > . ItemParam ;
1547
1552
var body = Expression . Call ( null , tupleFactoryMethod ,
1548
1553
ExpressionReplacer . ReplaceAll ( keySelector . Body , keySelector . Parameters , itemParam ) ,
1549
1554
ExpressionReplacer . ReplaceAll ( valueSelector . Body , valueSelector . Parameters , itemParam ) ) ;
0 commit comments