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


C# EdmModel.AddElements方法代码示例

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


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

示例1: Invalid_CastTests

        public void Invalid_CastTests(string path)
        {
            // Arrange
            EdmModel model = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            var vehicle = new EdmEntityType("NS", "Vehicle");
            var car = new EdmEntityType("NS", "Car", vehicle);
            var motorcycle = new EdmEntityType("NS", "Motorcycle", vehicle);
            model.AddElements(new IEdmSchemaElement[] { vehicle, car, motorcycle, container });

            container.AddEntitySet("Vehicles", vehicle);
            container.AddEntitySet("Cars", car);
            container.AddEntitySet("Motorcycles", motorcycle);

            // Act
            var exception = Assert.Throws<ODataException>(() => _parser.Parse(model, path));
            Assert.Contains("Invalid cast encountered.", exception.Message);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:18,代码来源:DefaultODataPathHandlerTest.cs

示例2: ActionOverloadResoultionTests

        [InlineData("Cars/NS.Vehicle/WashMultiple", "WashMultiple", "Collection([NS.Vehicle Nullable=False])")] // downcast
        public void ActionOverloadResoultionTests(string path, string actionName, string expectedEntityBound)
        {
            // Arrange
            EdmModel model = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            var vehicle = new EdmEntityType("NS", "Vehicle");
            var car = new EdmEntityType("NS", "Car", vehicle);
            var motorcycle = new EdmEntityType("NS", "Motorcycle", vehicle);
            model.AddElements(new IEdmSchemaElement[] { vehicle, car, motorcycle, container });

            var washVehicle = AddBindableAction(container, "Wash", vehicle, isCollection: false);
            var washCar = AddBindableAction(container, "Wash", car, isCollection: false);
            var washVehicles = AddBindableAction(container, "WashMultiple", vehicle, isCollection: true);
            var washCars = AddBindableAction(container, "WashMultiple", car, isCollection: true);

            container.AddEntitySet("Vehicles", vehicle);
            container.AddEntitySet("Cars", car);
            container.AddEntitySet("Motorcycles", motorcycle);

            // Act
            ODataPath odataPath = _parser.Parse(model, path);

            // Assert
            Assert.NotNull(odataPath);
            ActionPathSegment actionSegment = Assert.IsType<ActionPathSegment>(odataPath.Segments.Last());
            Assert.Equal("NS.Container." + actionName, actionSegment.ActionName);
            Assert.Equal(expectedEntityBound, actionSegment.Action.Parameters.First().Type.Definition.ToTraceString());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:29,代码来源:DefaultODataPathHandlerTest.cs

示例3: CastTests

        public void CastTests(string path, string expectedEdmType)
        {
            // Arrange
            EdmModel model = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            var vehicle = new EdmEntityType("NS", "Vehicle");
            var car = new EdmEntityType("NS", "Car", vehicle);
            var motorcycle = new EdmEntityType("NS", "Motorcycle", vehicle);
            model.AddElements(new IEdmSchemaElement[] { vehicle, car, motorcycle, container });

            container.AddEntitySet("Vehicles", vehicle);
            container.AddEntitySet("Cars", car);
            container.AddEntitySet("Motorcycles", motorcycle);

            // Act
            ODataPath odataPath = _parser.Parse(model, path);

            // Assert
            Assert.NotNull(odataPath);
            Assert.Equal(expectedEdmType, odataPath.EdmType.ToTraceString());
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:21,代码来源:DefaultODataPathHandlerTest.cs


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