本文整理汇总了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);
}
示例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());
}
示例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());
}