/// <summary> /// Created a SingleEntityCastNode with the given source node and the given type to cast to. /// </summary> /// <param name="source"> Source <see cref="SingleValueNode"/> that is being cast.</param> /// <param name="entityType">Type to cast to.</param> /// <exception cref="System.ArgumentNullException">Throws if the input entityType is null.</exception> public SingleEntityCastNode(SingleEntityNode source, IEdmEntityType entityType) { ExceptionUtils.CheckArgumentNotNull(entityType, "entityType"); this.source = source; this.navigationSource = source != null ? source.NavigationSource : null; this.entityTypeReference = new EdmEntityTypeReference(entityType, false); }
/// <summary> /// Creates a CollectionNavigationNode. /// </summary> /// <param name="navigationProperty">The navigation property that defines the collection node.</param> /// <param name="source">The parent of this collection navigation node.</param> /// <returns>The collection node.</returns> /// <exception cref="System.ArgumentNullException">Throws if the input source or navigation property is null.</exception> /// <exception cref="ArgumentException">Throws if the input navigation doesn't target a collection.</exception> public CollectionNavigationNode(IEdmNavigationProperty navigationProperty, SingleEntityNode source) : this(navigationProperty) { ExceptionUtils.CheckArgumentNotNull(source, "source"); this.source = source; this.navigationSource = source.NavigationSource != null?source.NavigationSource.FindNavigationTarget(navigationProperty) : null; }
/// <summary> /// Constructs a SingleNavigationNode. /// </summary> /// <param name="navigationProperty">The navigation property this node represents.</param> /// <param name="source">The previous node in the path.</param> /// <exception cref="System.ArgumentNullException">Throws if the input navigationProperty or source is null.</exception> /// <exception cref="ArgumentException">Throws if the input navigationProperty targets more than one entity.</exception> public SingleNavigationNode(IEdmNavigationProperty navigationProperty, SingleEntityNode source) { ExceptionUtils.CheckArgumentNotNull(navigationProperty, "navigationProperty"); ExceptionUtils.CheckArgumentNotNull(source, "source"); EdmMultiplicity multiplicity = navigationProperty.TargetMultiplicityTemporary(); if (multiplicity != EdmMultiplicity.One && multiplicity != EdmMultiplicity.ZeroOrOne) { throw new ArgumentException(ODataErrorStrings.Nodes_CollectionNavigationNode_MustHaveSingleMultiplicity); } this.source = source; this.navigationProperty = navigationProperty; this.entityTypeReference = (IEdmEntityTypeReference)this.NavigationProperty.Type; this.navigationSource = source.NavigationSource != null?source.NavigationSource.FindNavigationTarget(navigationProperty) : null; }
/// <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> /// <returns>A new CollectionNavigationNode or SingleNavigationNode to capture the navigation propety access.</returns> internal static QueryNode GetNavigationNode(IEdmNavigationProperty property, SingleEntityNode parent, IEnumerable<NamedValue> namedValues, BindingState state, KeyBinder keyBinder) { 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(property, parent); // 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 colleciton"); // Otherwise it's a single navigation property return new SingleNavigationNode(property, parent); }
private string BindNavigationPropertyNode(SingleEntityNode singleEntityNode, IEdmNavigationProperty edmNavigationProperty) { return Bind(singleEntityNode) + "." + edmNavigationProperty.Name; }