private void ValidateCollectionNode(CollectionNode node, ODataValidationSettings settings) { switch (node.Kind) { case QueryNodeKind.CollectionPropertyAccess: CollectionPropertyAccessNode propertyAccessNode = node as CollectionPropertyAccessNode; ValidateCollectionPropertyAccessNode(propertyAccessNode, settings); break; case QueryNodeKind.CollectionComplexNode: CollectionComplexNode collectionComplexNode = node as CollectionComplexNode; ValidateCollectionComplexNode(collectionComplexNode, settings); break; case QueryNodeKind.CollectionNavigationNode: CollectionNavigationNode navigationNode = node as CollectionNavigationNode; ValidateNavigationPropertyNode(navigationNode.Source, navigationNode.NavigationProperty, settings); break; case QueryNodeKind.CollectionResourceCast: ValidateCollectionResourceCastNode(node as CollectionResourceCastNode, settings); break; case QueryNodeKind.CollectionFunctionCall: case QueryNodeKind.CollectionResourceFunctionCall: case QueryNodeKind.CollectionOpenPropertyAccess: // Unused or have unknown uses. default: throw Error.NotSupported(SRResources.QueryNodeValidationNotSupported, node.Kind, typeof(FilterQueryValidator).Name); } }
/// <summary> /// We return the <see cref="ResourceRangeVariableReferenceNode"/> within a <see cref="QueryNode"/> /// </summary> /// <param name="node">The node to extract the ResourceRangeVariableReferenceNode.</param> /// <returns>The extracted ResourceRangeVariableReferenceNode.</returns> private ResourceRangeVariableReferenceNode GetResourceRangeVariableReferenceNode(QueryNode node) { if (node == null) { return(null); } switch (node.Kind) { case QueryNodeKind.SingleValuePropertyAccess: SingleValuePropertyAccessNode singleValuePropertyAccessNode = node as SingleValuePropertyAccessNode; return(GetResourceRangeVariableReferenceNode(singleValuePropertyAccessNode.Source)); case QueryNodeKind.Convert: ConvertNode convertNode = node as ConvertNode; return(GetResourceRangeVariableReferenceNode(convertNode.Source)); case QueryNodeKind.Any: AnyNode anyNode = node as AnyNode; return(GetResourceRangeVariableReferenceNode(anyNode.Source)); case QueryNodeKind.SingleValueFunctionCall: SingleValueFunctionCallNode singleValueFunctionCallNode = node as SingleValueFunctionCallNode; return(GetResourceRangeVariableReferenceNode(singleValueFunctionCallNode.Parameters.First())); case QueryNodeKind.ResourceRangeVariableReference: return(node as ResourceRangeVariableReferenceNode); case QueryNodeKind.SingleValueOpenPropertyAccess: SingleValueOpenPropertyAccessNode singleValueOpenPropertyAccessNode = node as SingleValueOpenPropertyAccessNode; return(GetResourceRangeVariableReferenceNode(singleValueOpenPropertyAccessNode.Source)); case QueryNodeKind.SingleComplexNode: SingleComplexNode singleComplexNode = node as SingleComplexNode; return(GetResourceRangeVariableReferenceNode(singleComplexNode.Source)); case QueryNodeKind.CollectionComplexNode: CollectionComplexNode collectionComplexNode = node as CollectionComplexNode; return(GetResourceRangeVariableReferenceNode(collectionComplexNode.Source)); case QueryNodeKind.CollectionNavigationNode: CollectionNavigationNode collectionNavigationNode = node as CollectionNavigationNode; return(GetResourceRangeVariableReferenceNode(collectionNavigationNode.Source)); case QueryNodeKind.SingleNavigationNode: SingleNavigationNode singleNavigationNode = node as SingleNavigationNode; return(GetResourceRangeVariableReferenceNode(singleNavigationNode.Source)); case QueryNodeKind.CollectionResourceFunctionCall: CollectionResourceFunctionCallNode collectionResourceFunctionCallNode = node as CollectionResourceFunctionCallNode; return(GetResourceRangeVariableReferenceNode(collectionResourceFunctionCallNode.Source)); case QueryNodeKind.SingleResourceFunctionCall: SingleResourceFunctionCallNode singleResourceFunctionCallNode = node as SingleResourceFunctionCallNode; return(GetResourceRangeVariableReferenceNode(singleResourceFunctionCallNode.Source)); } return(null); }
/// <summary> /// Translate a CollectionComplexNode. /// </summary> /// <param name="nodeIn">The node to be translated.</param> /// <returns>The translated node.</returns> public override QueryNode Visit(CollectionComplexNode nodeIn) { Contract.Assert(nodeIn != null); return(new CollectionComplexNode( (SingleResourceNode)nodeIn.Source.Accept(this), nodeIn.Property)); }
/// <summary> /// Visit a CollectionComplexNode /// </summary> /// <param name="nodeIn">the node to visit</param> /// <returns>true, indicating that the node has been visited.</returns> public override bool Visit(CollectionComplexNode nodeIn) { validate(nodeIn); validate(nodeIn.Property); validate(nodeIn.CollectionType.CollectionDefinition()); validate(nodeIn.ItemType.Definition); return(true); }
/// <summary> /// Writes collection complex property node to string. /// </summary> /// <param name="node">Node to write to string</param> /// <returns>String representation of node.</returns> private static string ToString(CollectionComplexNode node) { return(tabHelper.Prefix + "CollectionComplexNode" + tabHelper.Indent(() => tabHelper.Prefix + "Property = " + node.Property.Name + tabHelper.Prefix + "ItemType = " + node.ItemType + tabHelper.Prefix + "Source = " + ToString(node.Source) )); }
public override QueryNode Visit(CollectionComplexNode nodeIn) { SingleResourceNode?source = nodeIn.Source == null ? null : (SingleResourceNode)Visit(nodeIn.Source); if (nodeIn.Source != source) { nodeIn = new CollectionComplexNode(source, nodeIn.Property); } return(nodeIn); }
/// <summary> /// Binds a <see cref="CollectionComplexNode"/> to create a LINQ <see cref="Expression"/> that /// represents the semantics of the <see cref="CollectionComplexNode"/>. /// </summary> /// <param name="collectionComplexNode">The node to bind.</param> /// <returns>The LINQ <see cref="Expression"/> created.</returns> public virtual Expression BindCollectionComplexNode(CollectionComplexNode collectionComplexNode) { if (collectionComplexNode == null) { throw Error.ArgumentNull(nameof(collectionComplexNode)); } Expression source = Bind(collectionComplexNode.Source); return(CreatePropertyAccessExpression(source, collectionComplexNode.Property)); }
/// <summary> /// Translate a CollectionComplexNode. /// </summary> /// <param name="nodeIn">The node to be translated.</param> /// <returns>The translated node.</returns> public override QueryNode Visit(CollectionComplexNode nodeIn) { if (nodeIn == null) { throw Error.ArgumentNull(nameof(nodeIn)); } return(new CollectionComplexNode( (SingleResourceNode)nodeIn.Source.Accept(this), nodeIn.Property)); }
/// <summary> /// Override this method to validate collection complex property accessor. /// </summary> /// <remarks> /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code. /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance. /// </remarks> /// <param name="collectionComplexNode"></param> /// <param name="settings"></param> protected virtual void ValidateCollectionComplexNode(CollectionComplexNode collectionComplexNode, ODataValidationSettings settings) { Contract.Assert(collectionComplexNode != null); Contract.Assert(settings != null); // Check whether the property is filterable. IEdmProperty property = collectionComplexNode.Property; if (EdmHelpers.IsNotFilterable(property, _property, _structuredType, _model, _defaultQuerySettings.EnableFilter)) { throw new ODataException(Error.Format(SRResources.NotFilterablePropertyUsedInFilter, property.Name)); } ValidateQueryNode(collectionComplexNode.Source, settings); }
/// <summary> /// Override this method to validate collection complex property accessor. /// </summary> /// <remarks> /// This method is intended to be called from method overrides in subclasses. This method also supports unit-testing scenarios and is not intended to be called from user code. /// Call the Validate method to validate a <see cref="FilterQueryOption"/> instance. /// </remarks> /// <param name="collectionComplexNode"></param> /// <param name="settings"></param> public virtual void ValidateCollectionComplexNode(CollectionComplexNode collectionComplexNode, ODataValidationSettings settings) { if (collectionComplexNode == null) { throw Error.ArgumentNull("collectionComplexNode"); } if (settings == null) { throw Error.ArgumentNull("settings"); } // Check whether the property is filterable. IEdmProperty property = collectionComplexNode.Property; if (EdmHelpers.IsNotFilterable(property, _property, _structuredType, _model, _defaultQuerySettings.EnableFilter)) { throw new ODataException(Error.Format(SRResources.NotFilterablePropertyUsedInFilter, property.Name)); } ValidateQueryNode(collectionComplexNode.Source, settings); }
/// <summary> /// Translates a <see cref="CollectionComplexNode"/> into a corresponding <see cref="String"/>. /// </summary> /// <param name="node">The node to translate.</param> /// <returns>The translated String.</returns> public override String Visit(CollectionComplexNode node) { ExceptionUtils.CheckArgumentNotNull(node, "node"); return(this.TranslatePropertyAccess(node.Source, node.Property.Name)); }
public override void ValidateCollectionComplexNode(CollectionComplexNode collectionComplexNode, ODataValidationSettings settings) { IncrementCount("ValidateCollectionComplexNode"); base.ValidateCollectionComplexNode(collectionComplexNode, settings); }
/// <summary> /// Visit a CollectionComplexNode /// </summary> /// <param name="nodeIn">The node to visit</param> /// <returns>The translated expression</returns> public override Expression Visit(CollectionComplexNode nodeIn) { this.CheckArgumentNull(nodeIn, "CollectionComplexNode"); return(this.TranslatePropertyAccess(nodeIn.Source, nodeIn.Property)); }
public override string Visit(CollectionComplexNode nodeIn) { var navigationPath = GetNavigationPath(nodeIn); return($"{Constants.SQLJoinSymbol} x {Constants.SQLInSymbol} {Constants.SQLFieldNameSymbol}{Constants.SymbolDot}{navigationPath}{nodeIn.Property.Name}"); }
/// <summary> /// Binds a <see cref="CollectionComplexNode"/> to create a LINQ <see cref="Expression"/> that /// represents the semantics of the <see cref="CollectionComplexNode"/>. /// </summary> /// <param name="collectionComplexNode">The node to bind.</param> /// <returns>The LINQ <see cref="Expression"/> created.</returns> public virtual Expression BindCollectionComplexNode(CollectionComplexNode collectionComplexNode) { Expression source = Bind(collectionComplexNode.Source); return(CreatePropertyAccessExpression(source, collectionComplexNode.Property)); }
public override T Visit(CollectionComplexNode nodeIn) => DebuggerBreakVisited(nodeIn);