示例#1
0
        /// <summary>
        /// Bind the top level expand.
        /// </summary>
        /// <param name="tokenIn">the token to visit</param>
        /// <returns>a SelectExpand clause based on this ExpandToken</returns>
        public SelectExpandClause Bind(ExpandToken tokenIn)
        {
            ExceptionUtils.CheckArgumentNotNull(tokenIn, "tokenIn");

            // the top level represents $it then has only select populated..
            List <SelectItem> expandedTerms = new List <SelectItem>();

            if (tokenIn.ExpandTerms.Single().ExpandOption != null)
            {
                expandedTerms.AddRange(tokenIn.ExpandTerms.Single().ExpandOption.ExpandTerms.Select(this.GenerateExpandItem).Where(expandedNavigationSelectItem => expandedNavigationSelectItem != null));
            }

            // if there are any select items at this level then allSelected is false, otherwise it's true.
            bool isAllSelected = tokenIn.ExpandTerms.Single().SelectOption == null;
            SelectExpandClause topLevelExpand = new SelectExpandClause(expandedTerms, isAllSelected);

            if (!isAllSelected)
            {
                SelectBinder selectBinder = new SelectBinder(this.Model, this.EdmType, this.Configuration.Settings.SelectExpandLimit, topLevelExpand, this.configuration.Resolver);
                selectBinder.Bind(tokenIn.ExpandTerms.Single().SelectOption);
            }

            return(topLevelExpand);
        }
示例#2
0
        /// <summary>
        /// Decorate an expand tree using a select token.
        /// </summary>
        /// <param name="subExpand">the already built sub expand</param>
        /// <param name="currentNavProp">the current navigation property</param>
        /// <param name="select">the select token to use</param>
        /// <returns>A new SelectExpand clause decorated with the select token.</returns>
        private SelectExpandClause DecorateExpandWithSelect(SelectExpandClause subExpand, IEdmNavigationProperty currentNavProp, SelectToken select)
        {
            SelectBinder selectBinder = new SelectBinder(this.Model, currentNavProp.ToEntityType(), this.Settings.SelectExpandLimit, subExpand, this.configuration.Resolver);

            return(selectBinder.Bind(select));
        }