Esempio n. 1
0
        /// <summary>
        /// Builds an appropriate navigation query node (collection or single) for the given property and parent node.
        /// </summary>
        /// <param name="property">Navigation property.</param>
        /// <param name="parent">Parent Node.</param>
        /// <param name="namedValues">Named values (key values) that were included in the node we are binding, if any.</param>
        /// <param name="state">State of binding.</param>
        /// <param name="keyBinder">Object to perform binding on any key values that are present.</param>
        /// <param name="navigationSource">The navigation source of the navigation node.</param>
        /// <returns>A new CollectionNavigationNode or SingleNavigationNode to capture the navigation property access.</returns>
        internal static QueryNode GetNavigationNode(IEdmNavigationProperty property, SingleResourceNode parent, IEnumerable <NamedValue> namedValues, BindingState state, KeyBinder keyBinder, out IEdmNavigationSource navigationSource)
        {
            ExceptionUtils.CheckArgumentNotNull(property, "property");
            ExceptionUtils.CheckArgumentNotNull(parent, "parent");
            ExceptionUtils.CheckArgumentNotNull(state, "state");
            ExceptionUtils.CheckArgumentNotNull(keyBinder, "keyBinder");

            // Handle collection navigation property
            if (property.TargetMultiplicity() == EdmMultiplicity.Many)
            {
                CollectionNavigationNode collectionNavigationNode = new CollectionNavigationNode(parent, property, state.ParsedSegments);
                navigationSource = collectionNavigationNode.NavigationSource;

                // Doing key lookup on the collection navigation property
                if (namedValues != null)
                {
                    return(keyBinder.BindKeyValues(collectionNavigationNode, namedValues, state.Model));
                }

                // Otherwise it's just a normal collection of entities
                return(collectionNavigationNode);
            }

            Debug.Assert(namedValues == null || !namedValues.Any(), "namedValues should not exist if it isn't a collection");

            // Otherwise it's a single navigation property
            SingleNavigationNode singleNavigationNode = new SingleNavigationNode(parent, property, state.ParsedSegments);

            navigationSource = singleNavigationNode.NavigationSource;
            return(singleNavigationNode);
        }
Esempio n. 2
0
        protected string Bind(QueryNode node)
        {
            CollectionNode  collectionNode  = node as CollectionNode;
            SingleValueNode singleValueNode = node as SingleValueNode;

            if (collectionNode != null)
            {
                switch (node.Kind)
                {
                case QueryNodeKind.CollectionNavigationNode:
                    CollectionNavigationNode navigationNode = node as CollectionNavigationNode;
                    return(BindNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty));

                case QueryNodeKind.CollectionPropertyAccess:
                    return(BindCollectionPropertyAccessNode(node as CollectionPropertyAccessNode));
                }
            }
            else if (singleValueNode != null)
            {
                switch (node.Kind)
                {
                case QueryNodeKind.BinaryOperator:
                    return(BindBinaryOperatorNode(node as BinaryOperatorNode));

                case QueryNodeKind.Constant:
                    return(BindConstantNode(node as ConstantNode));

                case QueryNodeKind.Convert:
                    return(BindConvertNode(node as ConvertNode));

                //case QueryNodeKind.EntityRangeVariableReference:
                //    return BindRangeVariable((node as EntityRangeVariableReferenceNode).RangeVariable);

                //case QueryNodeKind.NonentityRangeVariableReference:
                //    return BindRangeVariable((node as NonentityRangeVariableReferenceNode).RangeVariable);

                case QueryNodeKind.SingleValuePropertyAccess:
                    return(BindPropertyAccessQueryNode(node as SingleValuePropertyAccessNode));

                case QueryNodeKind.UnaryOperator:
                    return(BindUnaryOperatorNode(node as UnaryOperatorNode));

                case QueryNodeKind.SingleValueFunctionCall:
                    return(BindSingleValueFunctionCallNode(node as SingleValueFunctionCallNode));

                case QueryNodeKind.SingleNavigationNode:
                    SingleNavigationNode navigationNode = node as SingleNavigationNode;
                    return(BindNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty));

                case QueryNodeKind.Any:
                    return(BindAnyNode(node as AnyNode));

                case QueryNodeKind.All:
                    return(BindAllNode(node as AllNode));
                }
            }

            throw new NotSupportedException(String.Format("Nodes of type {0} are not supported", node.Kind));
        }
Esempio n. 3
0
 /// <summary>
 /// Visit a SingleNavigationNode
 /// </summary>
 /// <param name="nodeIn">the node to visit</param>
 /// <returns>Defined by the implementer</returns>
 public virtual T Visit(SingleNavigationNode nodeIn)
 {
     throw new NotImplementedException();
 }