Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <summary>
        /// Bind a skip option
        /// </summary>
        /// <param name="syntax">a syntax tree containing the skip option</param>
        /// <param name="rangeVariable">the range variable that iterates over the top level collection</param>
        /// <param name="path">the top level path.</param>
        /// <returns>a nullable long representing this skip option</returns>
        public static long?BindSkip(SyntacticTree syntax, RangeVariable rangeVariable, ODataPath path)
        {
            if (syntax.Skip != null)
            {
                if (rangeVariable == null || !path.EdmType().IsEntityCollection())
                {
                    throw new ODataException(ODataErrorStrings.MetadataBinder_QueryOptionNotApplicable("$skip"));
                }

                return(MetadataBinder.ProcessSkip(syntax.Skip));
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Bind an inline count option
        /// </summary>
        /// <param name="syntax">The inline count option to bind.</param>
        /// <param name="path">the top level path</param>
        /// <returns>an InlineCountKind representing this inline count option</returns>
        public static InlineCountKind?BindInlineCount(SyntacticTree syntax, ODataPath path)
        {
            if (syntax.InlineCount != null)
            {
                if (!path.EdmType().IsEntityCollection())
                {
                    throw new ODataException(ODataErrorStrings.MetadataBinder_QueryOptionNotApplicable("$inlinecount"));
                }

                return(syntax.InlineCount.Value);
            }

            return(null);
        }
Пример #4
0
        /// <summary>
        /// Bind a filter option
        /// </summary>
        /// <param name="syntax">a syntactic tree containing the filter option</param>
        /// <param name="rangeVariable">the range variable that iterates over the top level collection.</param>
        /// <returns>A filter clause representing this filter option</returns>
        public FilterClause BindFilter(SyntacticTree syntax, RangeVariable rangeVariable)
        {
            if (syntax.Filter != null)
            {
                if (rangeVariable == null)
                {
                    throw new ODataException(ODataErrorStrings.MetadataBinder_QueryOptionNotApplicable("$filter"));
                }

                FilterBinder filterBinder = new FilterBinder(this.bindMethod, this.bindingState);
                return(filterBinder.BindFilter(syntax.Filter));
            }

            return(null);
        }
Пример #5
0
        /// <summary>
        /// Bind an orderby option
        /// </summary>
        /// <param name="syntax">a syntac tree containing the orderby option</param>
        /// <param name="rangeVariable">the range variable that iterates over the top level collection</param>
        /// <param name="path">the top level path</param>
        /// <returns>an OrderByClause representing this orderby option</returns>
        public OrderByClause BindOrderBy(SyntacticTree syntax, RangeVariable rangeVariable, ODataPath path)
        {
            if (syntax.OrderByTokens != null && syntax.OrderByTokens.Any())
            {
                if (rangeVariable == null || !path.EdmType().IsEntityCollection())
                {
                    throw new ODataException(ODataErrorStrings.MetadataBinder_QueryOptionNotApplicable("$orderby"));
                }

                OrderByBinder orderByBinder = new OrderByBinder(this.bindMethod);
                return(orderByBinder.BindOrderBy(this.bindingState, syntax.OrderByTokens));
            }

            return(null);
        }