static NhRelinqQueryParser() { MethodCallRegistry.Register( new[] { MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( ReflectionHelper.GetMethodDefinition(() => Queryable.Aggregate <object>(null, null))), MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( ReflectionHelper.GetMethodDefinition(() => Queryable.Aggregate <object, object>(null, null, null))) }, typeof(AggregateExpressionNode)); MethodCallRegistry.Register( new[] { MethodCallExpressionNodeTypeRegistry.GetRegisterableMethodDefinition( ReflectionHelper.GetMethodDefinition((List <object> l) => l.Contains(null))), }, typeof(ContainsExpressionNode)); MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("Fetch") }, typeof(FetchOneExpressionNode)); MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("FetchMany") }, typeof(FetchManyExpressionNode)); MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetch") }, typeof(ThenFetchOneExpressionNode)); MethodCallRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetchMany") }, typeof(ThenFetchManyExpressionNode)); MethodCallRegistry.Register( new[] { typeof(LinqExtensionMethods).GetMethod("Cacheable"), typeof(LinqExtensionMethods).GetMethod("CacheMode"), typeof(LinqExtensionMethods).GetMethod("CacheRegion"), }, typeof(CacheableExpressionNode)); }
public NHibernateNodeTypeProvider() { var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry(); methodInfoRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("Fetch") }, typeof(FetchOneExpressionNode)); methodInfoRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("FetchMany") }, typeof(FetchManyExpressionNode)); methodInfoRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetch") }, typeof(ThenFetchOneExpressionNode)); methodInfoRegistry.Register(new[] { typeof(EagerFetchingExtensionMethods).GetMethod("ThenFetchMany") }, typeof(ThenFetchManyExpressionNode)); methodInfoRegistry.Register( new[] { typeof(LinqExtensionMethods).GetMethod("Cacheable"), typeof(LinqExtensionMethods).GetMethod("CacheMode"), typeof(LinqExtensionMethods).GetMethod("CacheRegion"), }, typeof(CacheableExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => Queryable.AsQueryable(null)), ReflectionHelper.GetMethodDefinition(() => Queryable.AsQueryable <object>(null)), }, typeof(AsQueryableExpressionNode) ); var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider(); nodeTypeProvider.InnerProviders.Add(methodInfoRegistry); defaultNodeTypeProvider = nodeTypeProvider; }
public static IQueryable <T> WithOption <T>(this IQueryable <T> query, string options) { var method = ReflectionHelper.GetMethodDefinition(() => WithOption <object>(null, null)).MakeGenericMethod(typeof(T)); var callExpression = Expression.Call(method, query.Expression, Expression.Constant(options)); return(new NhQueryable <T>(query.Provider, callExpression)); }
public static IQueryable <T> CacheMode <T>(this IQueryable <T> query, CacheMode cacheMode) { var method = ReflectionHelper.GetMethodDefinition(() => CacheMode <object>(null, NHibernate.CacheMode.Normal)).MakeGenericMethod(typeof(T)); var callExpression = Expression.Call(method, query.Expression, Expression.Constant(cacheMode)); return(new NhQueryable <T>(query.Provider, callExpression)); }
public static IQueryable <T> Cacheable <T>(this IQueryable <T> query) { var method = ReflectionHelper.GetMethodDefinition(() => Cacheable <object>(null)).MakeGenericMethod(typeof(T)); var callExpression = Expression.Call(method, query.Expression); return(new NhQueryable <T>(query.Provider, callExpression)); }
public static IQueryable <T> Timeout <T>(this IQueryable <T> query, int timeout) { var method = ReflectionHelper.GetMethodDefinition(() => Timeout <object>(null, 0)).MakeGenericMethod(typeof(T)); var callExpression = Expression.Call(method, query.Expression, Expression.Constant(timeout)); return(new NhQueryable <T>(query.Provider, callExpression)); }
public NHibernateNodeTypeProvider() { var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry(); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null)) }, typeof(FetchOneExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null)) }, typeof(FetchManyExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null)) }, typeof(ThenFetchOneExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null)) }, typeof(ThenFetchManyExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => LinqExtensionMethods.Cacheable <object>(null)), ReflectionHelper.GetMethodDefinition(() => LinqExtensionMethods.CacheMode <object>(null, CacheMode.Normal)), ReflectionHelper.GetMethodDefinition(() => LinqExtensionMethods.CacheRegion <object>(null, null)), }, typeof(CacheableExpressionNode)); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => Queryable.AsQueryable(null)), ReflectionHelper.GetMethodDefinition(() => Queryable.AsQueryable <object>(null)), }, typeof(AsQueryableExpressionNode) ); methodInfoRegistry.Register( new[] { ReflectionHelper.GetMethodDefinition(() => LinqExtensionMethods.Timeout <object>(null, 0)), }, typeof(TimeoutExpressionNode) ); var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider(); nodeTypeProvider.InnerProviders.Add(methodInfoRegistry); defaultNodeTypeProvider = nodeTypeProvider; }
public virtual IQueryable CreateQuery(Expression expression) { MethodInfo m = ReflectionHelper.GetMethodDefinition((DefaultQueryProvider p) => p.CreateQuery <object>(null)).MakeGenericMethod(expression.Type.GetGenericArguments()[0]); return((IQueryable)m.Invoke(this, new[] { expression })); }