Esempio n. 1
0
        public override HqlTreeNode BuildHql(MethodInfo method, Expression targetObject, ReadOnlyCollection <Expression> arguments, HqlTreeBuilder treeBuilder, IHqlExpressionVisitor visitor)
        {
            string memberName;

            if (VisitorUtil.IsDynamicComponentDictionaryGetter(method, targetObject, arguments, visitor.SessionFactory, out memberName))
            {
                return(treeBuilder.Dot(visitor.Visit(targetObject).AsExpression(), treeBuilder.Ident(memberName)));
            }
            return(treeBuilder.Index(visitor.Visit(targetObject).AsExpression(), visitor.Visit(arguments[0]).AsExpression()));
        }
            protected override Expression VisitMethodCall(MethodCallExpression node)
            {
                if (ListIndexerGenerator.IsMethodSupported(node.Method))
                {
                    _hasIndexer = true;
                    return(base.Visit(
                               node.Object == null
                                                        ? Enumerable.First(node.Arguments) // q.Children.ElementAt(0)
                                                        : node.Object                      // q.Children[0]
                               ));
                }

                if (VisitorUtil.TryGetPotentialDynamicComponentDictionaryMember(node, out var memberName))
                {
                    _memberPaths.Push(new MemberMetadata(memberName, _convertType, _hasIndexer));
                    _convertType = null;
                    _hasIndexer  = false;
                    return(base.Visit(node.Object));
                }

                return(Visit(node));
            }