diff --git a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs index 59d84ed7a..1a864db69 100644 --- a/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs +++ b/Orm/Xtensive.Orm/Orm/QueryableExtensions.cs @@ -4,12 +4,8 @@ // Created by: Alexey Gamzov // Created: 2009.05.06 -using System; -using System.Collections.Generic; -using System.Linq; using System.Linq.Expressions; -using System.Threading; -using System.Threading.Tasks; +using System.Reflection; using JetBrains.Annotations; using Xtensive.Core; using Xtensive.Orm.Internals; @@ -23,6 +19,17 @@ namespace Xtensive.Orm /// public static partial class QueryableExtensions { + private static class Traits + { + public static readonly MethodInfo ExtensionTagMethodInfo = WellKnownMembers.Queryable.ExtensionTag.MakeGenericMethod([typeof(T)]); + } + + private static class Traits + { + public static readonly MethodInfo ExtensionLeftJoinMethodInfo + = WellKnownMembers.Queryable.ExtensionLeftJoin.MakeGenericMethod([typeof (TOuter), typeof(TInner), typeof(TKey), typeof(TResult)]); + } + /// /// Tags query with given string /// (inserts string as comment in SQL statement) for @@ -43,8 +50,7 @@ public static IQueryable Tag(this IQueryable source, throw new NotSupportedException(string.Format(errorMessage, providerType)); } - var genericMethod = WellKnownMembers.Queryable.ExtensionTag.MakeGenericMethod(new[] { typeof(TSource) }); - var expression = Expression.Call(null, genericMethod, new[] { source.Expression, Expression.Constant(tag)}); + var expression = Expression.Call(null, Traits.ExtensionTagMethodInfo, new[] { source.Expression, Expression.Constant(tag)}); return source.Provider.CreateQuery(expression); } @@ -340,8 +346,7 @@ public static IQueryable LeftOuterJoin(t throw new NotSupportedException(string.Format(errorMessage, outerProviderType)); } - var genericMethod = WellKnownMembers.Queryable.ExtensionLeftJoin.MakeGenericMethod(new[] {typeof (TOuter), typeof(TInner), typeof(TKey), typeof(TResult)}); - var expression = Expression.Call(null, genericMethod, new[] {outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector}); + var expression = Expression.Call(null, Traits.ExtensionLeftJoinMethodInfo, new[] {outer.Expression, GetSourceExpression(inner), outerKeySelector, innerKeySelector, resultSelector}); return outer.Provider.CreateQuery(expression); }