You are rewriting the namespace builder.Namespace = "Bookservice"; using builder.Namespace = "ShelfService"; .
To use two separate namespaces, you will need two separate instances of new ODataConventionModelBuilder();
Below is a description of OData V4
// Book OData Endpoint var book_builder = new ODataConventionModelBuilder(); // Book OData entity sets.. book_builder.EntitySet<Book>("Books"); // Book Bound Function..has to be located on the Tables Controller... book_builder.Namespace = "BookService"; book_builder.EntityType<Table>().Collection .Function("MostRecent") .Returns<DateTimeOffset>(); // Book Config config.MapODataServiceRoute( routeName: "OData - Book", routePrefix: "book", model: book_builder.GetEdmModel() ); // Shelf OData Endpoint var shelf_builder = new ODataConventionModelBuilder(); // Shelf OData Entity Sets shelf_builder.EntitySet<Shelf>("Shelves"); // Shelf Bound Function..has to be located on the Tables Controller... shelf_builder.Namespace = "ShelfService"; shelf_builder.EntityType<Shelf>() .Action("NearestEmptyShelf"); .Returns<whatever you planned on returning>() //Shelf Config config.MapODataServiceRoute( routeName: "OData - Shelf", routePrefix: "shelf", model: shelf_builder.GetEdmModel() );
It has been a while since I implemented this mechanism, but you may have to rewrite AttributeRoutingConvention to use related functions in multiple namespaces / controllers using the above method. I know that at some point I had a hiccup and I found a good method for the public class CustomAttributeRoutingConvention : AttributeRoutingConvention that used the public static class HttpConfigExt to provide CustomMapODataServiceRoute to fix this problem.
source share