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


C# EntityInstanceContext.GenerateSelfLink方法代码示例

本文整理汇总了C#中EntityInstanceContext.GenerateSelfLink方法的典型用法代码示例。如果您正苦于以下问题:C# EntityInstanceContext.GenerateSelfLink方法的具体用法?C# EntityInstanceContext.GenerateSelfLink怎么用?C# EntityInstanceContext.GenerateSelfLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityInstanceContext的用法示例。


在下文中一共展示了EntityInstanceContext.GenerateSelfLink方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateSelfLink_GeneratesExpectedSelfLink

        public void GenerateSelfLink_GeneratesExpectedSelfLink(bool includeCast, string expectedIdLink)
        {
            HttpRequestMessage request = GetODataRequest(_model.Model);
            var serializerContext = new ODataSerializerContext { Model = _model.Model, EntitySet = _model.Customers, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            string idLink = entityContext.GenerateSelfLink(includeCast);

            Assert.Equal(expectedIdLink, idLink);
        }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:10,代码来源:LinkGenerationHelpersTest.cs

示例2: GenerateSelfLink_WorksToGenerateExpectedSelfLink_ForSingleton

        public void GenerateSelfLink_WorksToGenerateExpectedSelfLink_ForSingleton(bool includeCast, string expectedIdLink)
        {
            // Arrange
            HttpRequestMessage request = GetODataRequest(_model.Model);
            var serializerContext = new ODataSerializerContext { Model = _model.Model, NavigationSource = _model.Mary, Url = request.GetUrlHelper() };
            var entityContext = new EntityInstanceContext(serializerContext, _model.SpecialCustomer.AsReference(), new { ID = 42 });

            // Act
            var idLink = entityContext.GenerateSelfLink(includeCast);

            // Assert
            Assert.Equal(expectedIdLink, idLink.ToString());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:13,代码来源:LinkGenerationHelpersTest.cs

示例3: GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForNonContainedNavigation

        public void GenerateNavigationLink_WorksToGenerateExpectedNavigationLink_ForNonContainedNavigation()
        {
            // Arrange
            IEdmEntityType myOrder = (IEdmEntityType)_model.Model.FindDeclaredType("NS.MyOrder");
            IEdmNavigationProperty orderLinesProperty = myOrder.NavigationProperties().Single(x => x.Name.Equals("NonContainedOrderLines"));

            var serializerContext = new ODataSerializerContext
            {
                Model = _model.Model,
                NavigationSource = _model.OrderLines,
                Path = new ODataPath(
                    new EntitySetPathSegment(_model.Model.FindDeclaredEntitySet("MyOrders")),
                    new KeyValuePathSegment("42"),
                    new NavigationPathSegment(orderLinesProperty),
                    new KeyValuePathSegment("21")),
                Url = GetODataRequest(_model.Model).GetUrlHelper(),
            };
            var entityContext = new EntityInstanceContext(serializerContext, _model.OrderLine.AsReference(), new { ID = 21 });

            // Act
            Uri uri = entityContext.GenerateSelfLink(false);

            // Assert
            Assert.Equal("http://localhost/OrderLines(21)", uri.AbsoluteUri);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:25,代码来源:LinkGenerationHelpersTest.cs


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