本文整理汇总了C#中Microsoft.OData.Core.UriParser.Semantic.SelectExpandClause.AddToSelectedItems方法的典型用法代码示例。如果您正苦于以下问题:C# SelectExpandClause.AddToSelectedItems方法的具体用法?C# SelectExpandClause.AddToSelectedItems怎么用?C# SelectExpandClause.AddToSelectedItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Core.UriParser.Semantic.SelectExpandClause
的用法示例。
在下文中一共展示了SelectExpandClause.AddToSelectedItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddExplicitNavPropLinksWhereNecessary
/// <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()));
}
}
}
示例2: SuccessfullyAddSelectionItems
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);
}