本文整理汇总了C#中Microsoft.Data.Edm.Library.EdmModel类的典型用法代码示例。如果您正苦于以下问题:C# EdmModel类的具体用法?C# EdmModel怎么用?C# EdmModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmModel类属于Microsoft.Data.Edm.Library命名空间,在下文中一共展示了EdmModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildEdmModel
public static IEdmModel BuildEdmModel(ODataModelBuilder builder)
{
if (builder == null)
{
throw Error.ArgumentNull("builder");
}
EdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer(builder.Namespace, builder.ContainerName);
// add types and sets, building an index on the way.
Dictionary<Type, IEdmStructuredType> edmTypeMap = model.AddTypes(builder.StructuralTypes);
Dictionary<string, EdmEntitySet> edmEntitySetMap = model.AddEntitySets(builder, container, edmTypeMap);
// add procedures
model.AddProcedures(builder.Procedures, container, edmTypeMap, edmEntitySetMap);
// finish up
model.AddElement(container);
// build the map from IEdmEntityType to IEdmFunctionImport
model.SetAnnotationValue<BindableProcedureFinder>(model, new BindableProcedureFinder(model));
return model;
}
开发者ID:jlamfers,项目名称:aspnetwebstack,代码行数:25,代码来源:EdmModelHelperMethods.cs
示例2: CreateCustomerProductsModel
private static EdmModel CreateCustomerProductsModel()
{
var model = new EdmModel();
var container = new EdmEntityContainer("defaultNamespace", "DefaultContainer");
model.AddElement(container);
var productType = new EdmEntityType("defaultNamespace", "Product");
model.AddElement(productType);
var customerType = new EdmEntityType("defaultNamespace", "Customer");
customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Products", Target = productType, TargetMultiplicity = EdmMultiplicity.Many });
productType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Customers", Target = customerType, TargetMultiplicity = EdmMultiplicity.Many });
model.AddElement(customerType);
var productSet = new EdmEntitySet(
container,
"Products",
productType);
container.AddElement(productSet);
var customerSet = new EdmEntitySet(
container,
"Customers",
customerType);
var productsNavProp = customerType.NavigationProperties().Single(np => np.Name == "Products");
customerSet.AddNavigationTarget(productsNavProp, productSet);
container.AddElement(customerSet);
return model;
}
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:34,代码来源:ODataUriHelperTest.cs
示例3: AdvancedMapODataServiceRoute_ConfiguresARoute_WithAnODataRouteConstraintAndVersionConstraints
public void AdvancedMapODataServiceRoute_ConfiguresARoute_WithAnODataRouteConstraintAndVersionConstraints()
{
// Arrange
HttpRouteCollection routes = new HttpRouteCollection();
IEdmModel model = new EdmModel();
string routeName = "name";
string routePrefix = "prefix";
var pathHandler = new DefaultODataPathHandler();
var conventions = new List<IODataRoutingConvention>();
// Act
routes.MapODataServiceRoute(routeName, routePrefix, model, pathHandler, conventions);
// Assert
IHttpRoute odataRoute = routes[routeName];
Assert.Single(routes);
Assert.Equal(routePrefix + "/{*odataPath}", odataRoute.RouteTemplate);
Assert.Equal(2, odataRoute.Constraints.Count);
var odataPathConstraint = Assert.Single(odataRoute.Constraints.Values.OfType<ODataPathRouteConstraint>());
Assert.Same(model, odataPathConstraint.EdmModel);
Assert.IsType<DefaultODataPathHandler>(odataPathConstraint.PathHandler);
Assert.NotNull(odataPathConstraint.RoutingConventions);
var odataVersionConstraint = Assert.Single(odataRoute.Constraints.Values.OfType<ODataVersionConstraint>());
Assert.Equal(ODataVersion.V1, odataVersionConstraint.MinVersion);
Assert.Equal(ODataVersion.V3, odataVersionConstraint.MaxVersion);
}
开发者ID:shailendra9,项目名称:WebApi,代码行数:28,代码来源:HttpRouteCollectionExtensionsTest.cs
示例4: ConvertToEdmEntityType
private EdmEntityType ConvertToEdmEntityType(JSchema schema, EdmModel model, string name)
{
var type = new EdmEntityType("namespace", name);
foreach (var property in schema.Properties)
{
if (property.Value.Type == null)
throw new Exception("Type specyfication missing.");
var structuralType = MapPropertyToStructuralType(property, schema, model);
if (structuralType != null)
{
type.AddStructuralProperty(property.Key, structuralType);
}
else
{
type.AddStructuralProperty(property.Key, ToEdmPrimitiveType(property.Value.Type.Value));
}
}
model.AddElement(type);
return type;
}
开发者ID:terianil,项目名称:JsonSchemaToEdmModel,代码行数:25,代码来源:JsonSchemaConverter.cs
示例5: GetModelID_AndThen_GetModel_ReturnsOriginalModel
public void GetModelID_AndThen_GetModel_ReturnsOriginalModel()
{
EdmModel model = new EdmModel();
string modelID = ModelContainer.GetModelID(model);
Assert.Same(model, ModelContainer.GetModel(modelID));
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:7,代码来源:ModelContainerTest.cs
示例6: GetModelID_Returns_DifferentIDForDifferentModels
public void GetModelID_Returns_DifferentIDForDifferentModels()
{
EdmModel model1 = new EdmModel();
EdmModel model2 = new EdmModel();
Assert.NotEqual(ModelContainer.GetModelID(model1), ModelContainer.GetModelID(model2));
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:7,代码来源:ModelContainerTest.cs
示例7: GetActionLinkBuilder_ReturnsDefaultActionLinkBuilder_IfNotSet
public void GetActionLinkBuilder_ReturnsDefaultActionLinkBuilder_IfNotSet()
{
// Arrange
IEdmModel model = new EdmModel();
IEdmEntityContainer container = new EdmEntityContainer("NS", "Container");
IEdmFunctionImport action = new EdmFunctionImport(container, "Action", returnType: null);
Assert.NotNull(model.GetActionLinkBuilder(action));
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:9,代码来源:EdmModelExtensionsTest.cs
示例8: GetEntitySetLinkBuilder_ReturnsDefaultEntitySetBuilder_IfNotSet
public void GetEntitySetLinkBuilder_ReturnsDefaultEntitySetBuilder_IfNotSet()
{
IEdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
EdmEntityType entityType = new EdmEntityType("NS", "Entity");
IEdmEntitySet entitySet = new EdmEntitySet(container, "EntitySet", entityType);
Assert.NotNull(model.GetEntitySetLinkBuilder(entitySet));
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:9,代码来源:EdmModelExtensionsTest.cs
示例9: PathHandlerGetter_ReturnsDefaultPathHandlerByDefault
public void PathHandlerGetter_ReturnsDefaultPathHandlerByDefault()
{
HttpRequestMessage request = new HttpRequestMessage();
IEdmModel model = new EdmModel();
request.ODataProperties().Model = model;
var pathHandler = request.ODataProperties().PathHandler;
Assert.NotNull(pathHandler);
Assert.IsType<DefaultODataPathHandler>(pathHandler);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:11,代码来源:HttpRequestMessageExtensionsTest.cs
示例10: GetODataPathHandlerReturnsDefaultPathHandlerByDefault
public void GetODataPathHandlerReturnsDefaultPathHandlerByDefault()
{
HttpRequestMessage request = new HttpRequestMessage();
IEdmModel model = new EdmModel();
request.SetEdmModel(model);
var pathHandler = request.GetODataPathHandler();
Assert.NotNull(pathHandler);
Assert.IsType<DefaultODataPathHandler>(pathHandler);
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataHttpRequestMessageExtensionsTest.cs
示例11: SimpleCustomerOrderModel
public static IEdmModel SimpleCustomerOrderModel()
{
var model = new EdmModel();
var customerType = new EdmEntityType("Default", "Customer");
customerType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
customerType.AddStructuralProperty("FirstName", EdmPrimitiveTypeKind.String);
customerType.AddStructuralProperty("LastName", EdmPrimitiveTypeKind.String);
IEdmTypeReference primitiveTypeReference = EdmCoreModel.Instance
.GetPrimitive(EdmPrimitiveTypeKind.String, isNullable: true);
customerType.AddStructuralProperty("City", primitiveTypeReference, defaultValue: null,
concurrencyMode: EdmConcurrencyMode.Fixed);
model.AddElement(customerType);
var orderType = new EdmEntityType("Default", "Order");
orderType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
orderType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
orderType.AddStructuralProperty("Shipment", EdmPrimitiveTypeKind.String);
model.AddElement(orderType);
var addressType = new EdmComplexType("Default", "Address");
addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("Country", EdmPrimitiveTypeKind.String);
addressType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
model.AddElement(addressType);
// Add navigations
customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Orders",
Target = orderType,
TargetMultiplicity = EdmMultiplicity.Many
});
orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
{
Name = "Customer",
Target = customerType,
TargetMultiplicity = EdmMultiplicity.One
});
var container = new EdmEntityContainer("Default", "Container");
var customerSet = container.AddEntitySet("Customers", customerType);
var orderSet = container.AddEntitySet("Orders", orderType);
customerSet.AddNavigationTarget(customerType.NavigationProperties().Single(np => np.Name == "Orders"), orderSet);
orderSet.AddNavigationTarget(orderType.NavigationProperties().Single(np => np.Name == "Customer"), customerSet);
EntitySetLinkBuilderAnnotation linkAnnotation = new MockEntitySetLinkBuilderAnnotation();
model.SetEntitySetLinkBuilder(customerSet, linkAnnotation);
model.SetEntitySetLinkBuilder(orderSet, linkAnnotation);
model.AddElement(container);
return model;
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:54,代码来源:SerializationTestsHelpers.cs
示例12: GetMetadata_Returns_EdmModelFromRequest
public void GetMetadata_Returns_EdmModelFromRequest()
{
IEdmModel model = new EdmModel();
ODataMetadataController controller = new ODataMetadataController();
controller.Request = new HttpRequestMessage();
controller.Request.ODataProperties().Model = model;
IEdmModel responseModel = controller.GetMetadata();
Assert.Equal(model, responseModel);
}
开发者ID:AndreGleichner,项目名称:aspnetwebstack,代码行数:11,代码来源:ODataMetaDataControllerTests.cs
示例13: MapArray
private IEdmTypeReference MapArray(KeyValuePair<string, JSchema> property, JSchema parent, EdmModel model)
{
var entityPrimitiveType = ToEdmPrimitiveType(property.Value.Items.Single().Type.Value);
var entityType = EdmCoreModel.Instance.GetPrimitiveType(entityPrimitiveType);
var collectionType = new EdmCollectionType(new EdmPrimitiveTypeReference(entityType, false));
bool isNullable = !parent.Required.Contains(property.Key);
return new EdmCollectionTypeReference(collectionType, isNullable);
}
开发者ID:terianil,项目名称:JsonSchemaToEdmModel,代码行数:12,代码来源:JsonSchemaConverter.cs
示例14: ToEdmModel
public IEdmModel ToEdmModel(JSchema schema)
{
var model = new EdmModel();
var container = new EdmEntityContainer("namespace", "containerName");
var rootType = ConvertToEdmEntityType(schema, model, "root");
container.AddEntitySet("root", rootType);
model.AddElement(container);
return model;
}
开发者ID:terianil,项目名称:JsonSchemaToEdmModel,代码行数:13,代码来源:JsonSchemaConverter.cs
示例15: ModelGetter_Returns_ModelSetter
public void ModelGetter_Returns_ModelSetter()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
IEdmModel model = new EdmModel();
// Act
request.ODataProperties().Model = model;
IEdmModel newModel = request.ODataProperties().Model;
// Assert
Assert.Same(model, newModel);
}
开发者ID:KevMoore,项目名称:aspnetwebstack,代码行数:13,代码来源:HttpRequestMessageExtensionsTest.cs
示例16: TableStorageQueryIndexInspector
static TableStorageQueryIndexInspector()
{
EdmModel = new EdmModel();
TableServiceEntity = new EdmEntityType("Glimpse.WindowsAzure.Storage", "TableServiceEntity");
TableServiceEntity.AddStructuralProperty("PartitionKey", EdmPrimitiveTypeKind.String);
TableServiceEntity.AddStructuralProperty("RowKey", EdmPrimitiveTypeKind.String);
TableServiceEntity.AddStructuralProperty("Timestamp", EdmPrimitiveTypeKind.DateTime);
EdmModel.AddElement(TableServiceEntity);
var container = new EdmEntityContainer("TestModel", "DefaultContainer");
container.AddEntitySet("Entities", TableServiceEntity);
EdmModel.AddElement(container);
}
开发者ID:jeffora,项目名称:Glimpse,代码行数:13,代码来源:TableStorageQueryIndexInspector.cs
示例17: SetEdmModelThenGetReturnsWhatYouSet
public void SetEdmModelThenGetReturnsWhatYouSet()
{
// Arrange
HttpRequestMessage request = new HttpRequestMessage();
IEdmModel model = new EdmModel();
// Act
request.SetEdmModel(model);
IEdmModel newModel = request.GetEdmModel();
// Assert
Assert.Same(model, newModel);
}
开发者ID:Rhombulus,项目名称:aspnetwebstack,代码行数:13,代码来源:ODataHttpRequestMessageExtensionsTest.cs
示例18: GetMetadata_Returns_EdmModelFromSetODataFormatter
public void GetMetadata_Returns_EdmModelFromSetODataFormatter()
{
IEdmModel model = new EdmModel();
IEnumerable<ODataMediaTypeFormatter> oDataFormatters = ODataMediaTypeFormatters.Create(model);
HttpConfiguration configuration = new HttpConfiguration();
configuration.Formatters.InsertRange(0, oDataFormatters);
ODataMetadataController controller = new ODataMetadataController();
controller.Request = new HttpRequestMessage();
controller.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = configuration;
IEdmModel responseModel = controller.GetMetadata();
Assert.Equal(model, responseModel);
}
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:14,代码来源:ODataMetaDataControllerTests.cs
示例19: GetActionLinkBuilder_After_SetActionLinkBuilder
public void GetActionLinkBuilder_After_SetActionLinkBuilder()
{
// Arrange
IEdmModel model = new EdmModel();
IEdmEntityContainer container = new EdmEntityContainer("NS", "Container");
IEdmFunctionImport action = new Mock<IEdmFunctionImport>().Object;
ActionLinkBuilder builder = new ActionLinkBuilder(_=> null, followsConventions: false);
// Act
model.SetActionLinkBuilder(action, builder);
var result = model.GetActionLinkBuilder(action);
// Assert
Assert.Same(builder, result);
}
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:15,代码来源:EdmModelExtensionsTest.cs
示例20: MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided
public void MapODataRoute_AddsBatchRoute_WhenBatchHandlerIsProvided()
{
HttpRouteCollection routes = new HttpRouteCollection();
IEdmModel model = new EdmModel();
string routeName = "name";
string routePrefix = "prefix";
var batchHandler = new DefaultODataBatchHandler(new HttpServer());
routes.MapODataRoute(routeName, routePrefix, model, batchHandler);
IHttpRoute batchRoute = routes["nameBatch"];
Assert.NotNull(batchRoute);
Assert.Same(batchHandler, batchRoute.Handler);
Assert.Equal("prefix/$batch", batchRoute.RouteTemplate);
}
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:15,代码来源:ODataHttpRouteCollectionExtensionsTest.cs
注:本文中的Microsoft.Data.Edm.Library.EdmModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论