I am currently working with OData using WebApi, and I am stuck with adding multiple namespaces in the IEdmModel GetModel()WebApiConfig file. Below is the method that I am currently using
public static IEdmModel GetModel()
{
ODataModelBuilder builder = new ODataConventionModelBuilder();
var product= builder.EntitySet<Product>("Products");
builder.EntitySet<Customer>("Customers");
builder.EntitySet<CustomerAddress>("CustomerAddresses");
builder.EntitySet<CustomerEmail>("CustomerEmails");
builder.EntitySet<CustomerPhone>("CustomerPhones");
builder.EntitySet<Country>("Countries");
builder.EntitySet<State>("States");
builder.EntitySet<CustomerStore>("CustomerStores");
builder.Namespace = "StateService";
builder.EntityType<State>().Collection.Function("GetStatesByCountry").ReturnsCollectionFromEntitySet<State>("States");
builder.Namespace = "ProductCategoryService";
builder.EntityType<ProductCategory>().Collection.Function("GetProductCategories").ReturnsCollectionFromEntitySet<ProductCategory>("ProductCategories");
return builder.GetEdmModel();
}
If I add another namespace, it will override
builder.Namespace = "StateService";
builder.Namespace = "ProductCategoryService";
My problem is whether there is any approach to avoid this problem. Any help would be greatly appreciated.
source
share