本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmEntitySet.FindNavigationTarget方法的典型用法代码示例。如果您正苦于以下问题:C# EdmEntitySet.FindNavigationTarget方法的具体用法?C# EdmEntitySet.FindNavigationTarget怎么用?C# EdmEntitySet.FindNavigationTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.OData.Edm.Library.EdmEntitySet
的用法示例。
在下文中一共展示了EdmEntitySet.FindNavigationTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EdmSingletonBasicNavigationPropertyBindingTest
public void EdmSingletonBasicNavigationPropertyBindingTest()
{
var internalOrderProperty = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo(){Name = "InternalOrder", Target = this.orderType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne});
var externalOrderProperty = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo(){Name = "ExternalOrders", Target = this.orderType, TargetMultiplicity = EdmMultiplicity.Many});
var customerProductProperty = customerType.AddBidirectionalNavigation(
new EdmNavigationPropertyInfo() { Name = "Products", Target = this.productType, TargetMultiplicity = EdmMultiplicity.Many },
new EdmNavigationPropertyInfo() { Name = "Buyer", Target = this.customerType, TargetMultiplicity = EdmMultiplicity.One });
var orderSet = new EdmEntitySet(this.entityContainer, "Orders", this.orderType);
var productSet = new EdmEntitySet(this.entityContainer, "Products", this.productType);
var vipCustomer = new EdmSingleton(this.entityContainer, "VIP", this.customerType);
vipCustomer.NavigationPropertyBindings.Should().HaveCount(0);
vipCustomer.AddNavigationTarget(internalOrderProperty, orderSet);
vipCustomer.AddNavigationTarget(externalOrderProperty, orderSet);
vipCustomer.AddNavigationTarget(customerProductProperty, productSet);
vipCustomer.NavigationPropertyBindings.Should().HaveCount(3)
.And.Contain(m => m.NavigationProperty == internalOrderProperty && m.Target == orderSet)
.And.Contain(m => m.NavigationProperty == externalOrderProperty && m.Target == orderSet)
.And.Contain(m=>m.NavigationProperty == customerProductProperty && m.Target == productSet);
vipCustomer.FindNavigationTarget(internalOrderProperty).Should().Be(orderSet);
vipCustomer.FindNavigationTarget(externalOrderProperty).Should().Be(orderSet);
vipCustomer.FindNavigationTarget(customerProductProperty).Should().Be(productSet);
productSet.AddNavigationTarget(customerProductProperty.Partner, vipCustomer);
productSet.FindNavigationTarget(customerProductProperty.Partner).Should().Be(vipCustomer);
}