/// <summary> /// Bind a select and expand option. /// </summary> /// <param name="syntax">A syntax tree containing the select and expand options to bind</param> /// <param name="path">the top level path</param> /// <param name="configuration">The configuration to use for binding.</param> /// <returns>a select expand clause bound to metadata</returns> public static SelectExpandClause BindSelectExpand(SyntacticTree syntax, ODataPath path, ODataUriParserConfiguration configuration) { if (syntax.Select != null || syntax.Expand != null) { if (!path.EdmType().IsEntityCollection() && !path.EdmType().IsEntity()) { throw new ODataException(ODataErrorStrings.MetadataBinder_QueryOptionNotApplicable("$select or $expand")); } return(SelectExpandSemanticBinder.Parse((IEdmEntityType)((IEdmCollectionTypeReference)path.EdmType()).ElementType().Definition, path.EntitySet(), syntax.Expand, syntax.Select, configuration)); } return(null); }
/// <summary> /// Parses the <paramref name="select"/> and <paramref name="expand"/> clauses on the given <paramref name="elementType"/>, binding /// the text into a metadata-bound list of properties to be selected using the provided model. /// </summary> /// <param name="select">String representation of the select expression from the URI.</param> /// <param name="expand">String representation of the expand expression from the URI.</param> /// <param name="elementType">Type that the select and expand clauses are projecting.</param> /// <param name="entitySet">EntitySet that the elements being filtered are from.</param> /// <returns>A <see cref="SelectExpandClause"/> representing the metadata bound orderby expression.</returns> private SelectExpandClause ParseSelectAndExpandImplementation(string select, string expand, IEdmEntityType elementType, IEdmEntitySet entitySet) { DebugUtils.CheckNoExternalCallers(); ExceptionUtils.CheckArgumentNotNull(this.configuration.Model, "model"); ExceptionUtils.CheckArgumentNotNull(elementType, "elementType"); ISelectExpandTermParser selectParser = SelectExpandTermParserFactory.Create(select, this.Settings); SelectToken selectToken = selectParser.ParseSelect(); ISelectExpandTermParser expandParser = SelectExpandTermParserFactory.Create(expand, this.Settings); ExpandToken expandToken = expandParser.ParseExpand(); return(SelectExpandSemanticBinder.Parse(elementType, entitySet, expandToken, selectToken, this.configuration)); }