Example #1
0
        public NHibernateNodeTypeProvider()
        {
            var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry();

            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null)) },
                typeof(FetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null)) },
                typeof(FetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null)) },
                typeof(ThenFetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null)) },
                typeof(ThenFetchManyExpressionNode));

            methodInfoRegistry.Register(
                new[]
            {
                ReflectHelper.GetMethodDefinition(() => Queryable.AsQueryable(null)),
                ReflectHelper.GetMethodDefinition(() => Queryable.AsQueryable <object>(null)),
            }, typeof(AsQueryableExpressionNode)
                );

            methodInfoRegistry.Register(new[] { LinqExtensionMethods.SetOptionsDefinition }, typeof(OptionsExpressionNode));

            var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();

            nodeTypeProvider.InnerProviders.Add(methodInfoRegistry);
            defaultNodeTypeProvider = nodeTypeProvider;
        }
        public NHibernateNodeTypeProvider()
        {
            var methodInfoRegistry = new MethodInfoBasedNodeTypeRegistry();

            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.Fetch <object, object>(null, null)) },
                typeof(FetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.FetchMany <object, object>(null, null)) },
                typeof(FetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetch <object, object, object>(null, null)) },
                typeof(ThenFetchOneExpressionNode));
            methodInfoRegistry.Register(
                new[] { ReflectHelper.GetMethodDefinition(() => EagerFetchingExtensionMethods.ThenFetchMany <object, object, object>(null, null)) },
                typeof(ThenFetchManyExpressionNode));
            methodInfoRegistry.Register(
                new[]
            {
                ReflectHelper.GetMethodDefinition(() => default(IQueryable <object>).WithLock(LockMode.Read)),
                ReflectHelper.GetMethodDefinition(() => default(IEnumerable <object>).WithLock(LockMode.Read))
            },
                typeof(LockExpressionNode));

            var nodeTypeProvider = ExpressionTreeParser.CreateDefaultNodeTypeProvider();

            nodeTypeProvider.InnerProviders.Add(methodInfoRegistry);
            defaultNodeTypeProvider = nodeTypeProvider;
        }