当前位置: 首页>>代码示例>>C#>>正文


C# EdmEntitySet.FindNavigationTarget方法代码示例

本文整理汇总了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);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:EdmSingletonTests.cs


注:本文中的Microsoft.OData.Edm.Library.EdmEntitySet.FindNavigationTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。