Esempio n. 1
0
        /// <summary>
        /// Binds an Count segment token.
        /// </summary>
        /// <param name="countSegmentToken">The Count segment token to bind.</param>
        /// <param name="state">State of the metadata binding.</param>
        /// <returns>The bound Count segment token.</returns>
        internal QueryNode BindCountSegment(CountSegmentToken countSegmentToken)
        {
            ExceptionUtils.CheckArgumentNotNull(countSegmentToken, "countSegmentToken");

            QueryNode      source = this.bindMethod(countSegmentToken.NextToken);
            CollectionNode node   = source as CollectionNode;

            if (node == null)
            {
                throw new ODataException(ODataErrorStrings.MetadataBinder_CountSegmentNextTokenNotCollectionValue());
            }

            FilterClause filterClause = null;
            SearchClause searchClause = null;

            BindingState innerBindingState = new BindingState(state.Configuration);

            innerBindingState.ImplicitRangeVariable = NodeFactory.CreateParameterNode(ExpressionConstants.It, node);
            MetadataBinder binder = new MetadataBinder(innerBindingState);

            if (countSegmentToken.FilterOption != null)
            {
                FilterBinder filterBinder = new FilterBinder(binder.Bind, innerBindingState);
                filterClause = filterBinder.BindFilter(countSegmentToken.FilterOption);
            }

            if (countSegmentToken.SearchOption != null)
            {
                SearchBinder searchBinder = new SearchBinder(binder.Bind);
                searchClause = searchBinder.BindSearch(countSegmentToken.SearchOption);
            }

            return(new CountNode(node, filterClause, searchClause));
        }
Esempio n. 2
0
        /// <summary>
        /// Binds a CountSegment token.
        /// </summary>
        /// <param name="countSegmentToken">The CountSegment token to bind.</param>
        /// <returns>The bound CountSegment token.</returns>
        protected virtual QueryNode BindCountSegment(CountSegmentToken countSegmentToken)
        {
            CountSegmentBinder countSegmentBinder = new CountSegmentBinder(this.Bind, this.BindingState);

            return(countSegmentBinder.BindCountSegment(countSegmentToken));
        }