var customerType = new EdmEntityType("Namespace", "Customer"); customerType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32); customerType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String); customerType.AddStructuralProperty("Email", EdmPrimitiveTypeKind.String);
var orderType = new EdmEntityType("Namespace", "Order"); orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32); orderType.AddStructuralProperty("Title", EdmPrimitiveTypeKind.String); orderType.AddStructuralProperty("Amount", EdmPrimitiveTypeKind.Decimal); var customerProperty = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
var supplierType = new EdmEntityType("Namespace", "Supplier"); supplierType.Key(s => s.Property("Id")); supplierType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32); supplierType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String); supplierType.AddStructuralProperty("Address", EdmPrimitiveTypeKind.String); var productsProperty = supplierType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Products", Target = productType, TargetMultiplicity = EdmMultiplicity.Many }, new EdmNavigationPropertyInfo { Name = "Supplier", Target = supplierType, TargetMultiplicity = EdmMultiplicity.One });This code creates an instance of EdmEntityType for a Supplier entity type with three properties: Id, Name, and Address. It also adds a bidirectional navigation property "Products" that references the Product entity type and a navigation property "Supplier" that references itself. To use Microsoft.OData.Edm.Library, you can install the "Microsoft.OData.Edm" package from NuGet.