本文整理汇总了C#中Microsoft.Data.Edm.Library.EdmModel.SetEntitySetLinkBuilder方法的典型用法代码示例。如果您正苦于以下问题:C# EdmModel.SetEntitySetLinkBuilder方法的具体用法?C# EdmModel.SetEntitySetLinkBuilder怎么用?C# EdmModel.SetEntitySetLinkBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Data.Edm.Library.EdmModel
的用法示例。
在下文中一共展示了EdmModel.SetEntitySetLinkBuilder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: GetEntitySetLinkBuilder_After_SetEntitySetLinkBuilder
public void GetEntitySetLinkBuilder_After_SetEntitySetLinkBuilder()
{
// Arrange
IEdmModel model = new EdmModel();
EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
EdmEntityType entityType = new EdmEntityType("NS", "Entity");
IEdmEntitySet entitySet = new EdmEntitySet(container, "EntitySet", entityType);
EntitySetLinkBuilderAnnotation entitySetLinkBuilder = new EntitySetLinkBuilderAnnotation();
// Act
model.SetEntitySetLinkBuilder(entitySet, entitySetLinkBuilder);
var result = model.GetEntitySetLinkBuilder(entitySet);
// Assert
Assert.Same(entitySetLinkBuilder, result);
}