4
4
// Created by: Alexey Gamzov
5
5
// Created: 2009.05.06
6
6
7
- using System ;
8
- using System . Collections . Generic ;
9
- using System . Linq ;
10
7
using System . Linq . Expressions ;
11
- using System . Threading ;
12
- using System . Threading . Tasks ;
8
+ using System . Reflection ;
13
9
using JetBrains . Annotations ;
14
10
using Xtensive . Core ;
15
11
using Xtensive . Orm . Internals ;
@@ -23,6 +19,17 @@ namespace Xtensive.Orm
23
19
/// </summary>
24
20
public static partial class QueryableExtensions
25
21
{
22
+ private static class Traits < T >
23
+ {
24
+ public static readonly MethodInfo ExtensionTagMethodInfo = WellKnownMembers . Queryable . ExtensionTag . MakeGenericMethod ( [ typeof ( T ) ] ) ;
25
+ }
26
+
27
+ private static class Traits < TOuter , TInner , TKey , TResult >
28
+ {
29
+ public static readonly MethodInfo ExtensionLeftJoinMethodInfo
30
+ = WellKnownMembers . Queryable . ExtensionLeftJoin . MakeGenericMethod ( [ typeof ( TOuter ) , typeof ( TInner ) , typeof ( TKey ) , typeof ( TResult ) ] ) ;
31
+ }
32
+
26
33
/// <summary>
27
34
/// Tags query with given <paramref name="tag"/> string
28
35
/// (inserts string as comment in SQL statement) for
@@ -43,8 +50,7 @@ public static IQueryable<TSource> Tag<TSource>(this IQueryable<TSource> source,
43
50
throw new NotSupportedException ( string . Format ( errorMessage , providerType ) ) ;
44
51
}
45
52
46
- var genericMethod = WellKnownMembers . Queryable . ExtensionTag . MakeGenericMethod ( new [ ] { typeof ( TSource ) } ) ;
47
- var expression = Expression . Call ( null , genericMethod , new [ ] { source . Expression , Expression . Constant ( tag ) } ) ;
53
+ var expression = Expression . Call ( null , Traits < TSource > . ExtensionTagMethodInfo , new [ ] { source . Expression , Expression . Constant ( tag ) } ) ;
48
54
return source . Provider . CreateQuery < TSource > ( expression ) ;
49
55
}
50
56
@@ -340,8 +346,7 @@ public static IQueryable<TResult> LeftOuterJoin<TOuter, TInner, TKey, TResult>(t
340
346
throw new NotSupportedException ( string . Format ( errorMessage , outerProviderType ) ) ;
341
347
}
342
348
343
- var genericMethod = WellKnownMembers . Queryable . ExtensionLeftJoin . MakeGenericMethod ( new [ ] { typeof ( TOuter ) , typeof ( TInner ) , typeof ( TKey ) , typeof ( TResult ) } ) ;
344
- var expression = Expression . Call ( null , genericMethod , new [ ] { outer . Expression , GetSourceExpression ( inner ) , outerKeySelector , innerKeySelector , resultSelector } ) ;
349
+ var expression = Expression . Call ( null , Traits < TOuter , TInner , TKey , TResult > . ExtensionLeftJoinMethodInfo , new [ ] { outer . Expression , GetSourceExpression ( inner ) , outerKeySelector , innerKeySelector , resultSelector } ) ;
345
350
return outer . Provider . CreateQuery < TResult > ( expression ) ;
346
351
}
347
352
0 commit comments