using Microsoft.AspNet.OData.Builder; ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfigurationcustomerEntityType = builder.EntityType (); customerEntityType.HasKey(c => c.Id); customerEntityType.Property(c => c.Name); customerEntityType.CollectionProperty(c => c.Orders);
using Microsoft.AspNet.OData.Builder; ODataModelBuilder builder = new ODataModelBuilder(); EntityTypeConfigurationIn this example, we define two entity types, Order and Customer, and create a relationship between them using the HasMany and HasForeignKey methods. We also create an entity set for the Customers entity type and define a custom action called GetOrders that returns a collection of Orders. The package library for ODataModelBuilder is Microsoft.AspNet.OData.orderEntityType = builder.EntityType (); orderEntityType.HasKey(o => o.Id); orderEntityType.Property(o => o.Date); orderEntityType.Property(o => o.Amount); EntityTypeConfiguration customerEntityType = builder.EntityType (); customerEntityType.HasKey(c => c.Id); customerEntityType.Property(c => c.Name); customerEntityType.CollectionProperty(c => c.Orders); customerEntityType.HasMany(c => c.Orders).HasForeignKey(o => o.CustomerId); EntitySetConfiguration customerEntitySet = builder.EntitySet ("Customers"); customerEntitySet.EntityType.HasKey(c => c.Id); customerEntitySet.EntityType.Action("GetOrders").ReturnsCollectionFromEntitySet ("Orders");