private static SelectExpandClause CreateSelectExpandClauseNestedSelectWithComplexType() { ODataSelectPath personNamePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonNameProp())); ODataSelectPath personShoePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonFavoriteDateProp())); ODataSelectPath addrPath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonAddressProp())); ODataSelectPath cityPath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetAddressCityProperty())); var cityClause = new SelectExpandClause(new List <SelectItem>(), false); cityClause.AddToSelectedItems(new PathSelectItem(cityPath)); var addritem = new PathSelectItem(addrPath); addritem.SelectAndExpand = cityClause; var addritem1 = new PathSelectItem(addrPath); var clause = new SelectExpandClause(new List <SelectItem>(), false); clause.AddToSelectedItems(new PathSelectItem(personShoePath)); clause.AddToSelectedItems(new PathSelectItem(personNamePath)); clause.AddToSelectedItems(addritem); clause.AddToSelectedItems(addritem1); return(clause); }
/// <summary> /// Add any explicit nav prop links to a select expand clause as necessary. /// </summary> /// <param name="clause">the select expand clause to modify.</param> public static void AddExplicitNavPropLinksWhereNecessary(SelectExpandClause clause) { IEnumerable <SelectItem> selectItems = clause.SelectedItems; // make sure that there are already selects for this level, otherwise we change the select semantics. bool anyPathSelectItems = selectItems.Any(x => x is PathSelectItem); // if there are selects for this level, then we need to add nav prop select items for each // expanded nav prop IEnumerable <ODataSelectPath> selectedPaths = selectItems.OfType <PathSelectItem>().Select(item => item.SelectedPath); foreach (ExpandedNavigationSelectItem navigationSelect in selectItems.Where(I => I.GetType() == typeof(ExpandedNavigationSelectItem))) { if (anyPathSelectItems && !selectedPaths.Any(x => x.Equals(navigationSelect.PathToNavigationProperty.ToSelectPath()))) { clause.AddToSelectedItems(new PathSelectItem(navigationSelect.PathToNavigationProperty.ToSelectPath())); } AddExplicitNavPropLinksWhereNecessary(navigationSelect.SelectAndExpand); } foreach (ExpandedReferenceSelectItem navigationSelect in selectItems.Where(I => I.GetType() == typeof(ExpandedReferenceSelectItem))) { if (anyPathSelectItems && !selectedPaths.Any(x => x.Equals(navigationSelect.PathToNavigationProperty.ToSelectPath()))) { clause.AddToSelectedItems(new PathSelectItem(navigationSelect.PathToNavigationProperty.ToSelectPath())); } } }
public void SuccessfullyAddSelectionItems() { ODataSelectPath personNamePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonNameProp())); ODataSelectPath personShoePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonShoeProp())); var clause = new SelectExpandClause(new List <ExpandedNavigationSelectItem>(), false); clause.AddToSelectedItems(new PathSelectItem(personShoePath)); clause.AddToSelectedItems(new PathSelectItem(personNamePath)); clause.SelectedItems.Should().HaveCount(2).And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath == personNamePath).And.Contain(x => x is PathSelectItem && x.As <PathSelectItem>().SelectedPath == personShoePath); }
private static SelectExpandClause CreateSelectExpandClauseMultiSelect() { ODataSelectPath personNamePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonNameProp())); ODataSelectPath personShoePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonShoeProp())); var clause = new SelectExpandClause(new List <SelectItem>(), false); clause.AddToSelectedItems(new PathSelectItem(personShoePath)); clause.AddToSelectedItems(new PathSelectItem(personNamePath)); return(clause); }
public void SuccessfullyAddSelectionItems() { ODataSelectPath personNamePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonNameProp())); ODataSelectPath personShoePath = new ODataSelectPath(new PropertySegment(HardCodedTestModel.GetPersonShoeProp())); var clause = new SelectExpandClause(new List <ExpandedNavigationSelectItem>(), false); clause.AddToSelectedItems(new PathSelectItem(personShoePath)); clause.AddToSelectedItems(new PathSelectItem(personNamePath)); Assert.Equal(2, clause.SelectedItems.Count()); Assert.Contains(clause.SelectedItems, x => x is PathSelectItem && ((PathSelectItem)x).SelectedPath == personNamePath); Assert.Contains(clause.SelectedItems, x => x is PathSelectItem && ((PathSelectItem)x).SelectedPath == personShoePath); }
private static SelectExpandClause CreateSelectExpandClauseAllSelectedWithNamespace() { var clause = new SelectExpandClause(new List <SelectItem>(), true); clause.AddToSelectedItems(new NamespaceQualifiedWildcardSelectItem("namespace")); return(clause); }
private static SelectExpandClause CreateSelectExpandClauseAllSelected() { var clause = new SelectExpandClause(new List <SelectItem>(), true); clause.AddToSelectedItems(new WildcardSelectItem()); return(clause); }