示例#1
0
 /// <summary>
 /// Create an Expand item using a nav prop, its entity set and a SelectExpandClause
 /// </summary>
 /// <param name="pathToNavigationProperty">the path to the navigation property for this expand item, including any type segments</param>
 /// <param name="entitySet">the entity set for this ExpandItem</param>
 /// <param name="selectExpandOption">This level select and any sub expands for this expand item.</param>
 /// <exception cref="System.ArgumentNullException">Throws if input pathToNavigationProperty is null.</exception>
 public ExpandedNavigationSelectItem(ODataExpandPath pathToNavigationProperty, IEdmEntitySet entitySet, SelectExpandClause selectExpandOption)
     : this(pathToNavigationProperty, entitySet, null, null, null, null, null, selectExpandOption)
 {
 }
示例#2
0
        /// <summary>
        /// Prune off any unneccessary expands
        /// </summary>
        /// <param name="clauseToPrune">the clause to prune</param>
        /// <returns>a pruned tree.</returns>
        internal static SelectExpandClause PruneSelectExpandTree(SelectExpandClause clauseToPrune)
        {
            DebugUtils.CheckNoExternalCallers();

            // prune all child nodes first, then prune this node (Post-Order Tree traversal)
            if (clauseToPrune == null)
            {
                return(null);
            }

            // if the selection on a clause is still unknown then it means it was expanded but never
            // selected, in which case it should be pruned out of the tree.
            if (clauseToPrune.Selection is UnknownSelection)
            {
                return(null);
            }

            if (clauseToPrune.Selection is AllSelection)
            {
                return(clauseToPrune);
            }

            if (clauseToPrune.Expansion != null)
            {
                List <ExpandedNavigationSelectItem> newChildExpandItems = new List <ExpandedNavigationSelectItem>();

                // build a new list of child expand items for this level, pruning off any
                // unneccessary expand items in the process.
                foreach (ExpandedNavigationSelectItem childExpand in clauseToPrune.Expansion.ExpandItems)
                {
                    SelectExpandClause newSubExpand = PruneSelectExpandTree(childExpand.SelectAndExpand);
                    if (newSubExpand == childExpand.SelectAndExpand)
                    {
                        newChildExpandItems.Add(childExpand);
                    }
                    else if (newSubExpand != null)
                    {
                        newChildExpandItems.Add(new ExpandedNavigationSelectItem(
                                                    childExpand.PathToNavigationProperty,
                                                    childExpand.EntitySet,
                                                    childExpand.FilterOption,
                                                    childExpand.OrderByOption,
                                                    childExpand.TopOption,
                                                    childExpand.SkipOption,
                                                    childExpand.InlineCountOption,
                                                    newSubExpand));
                    }
                }

                if (newChildExpandItems.Count == 0 && clauseToPrune.Selection is ExpansionsOnly)
                {
                    return(null);
                }
                else
                {
                    return(new SelectExpandClause(clauseToPrune.Selection, new Expansion(newChildExpandItems)));
                }
            }
            else
            {
                if (clauseToPrune.Selection is ExpansionsOnly)
                {
                    return(null);
                }
                else
                {
                    return(clauseToPrune);
                }
            }
        }