Last post Jan 31, 2020 06:46 PM by sheamus08
Jan 29, 2020 06:58 PM|sheamus08|LINK
I have an Microsoft.Odata.Edm.IEdmModel and I am trying to determine what EntitySet each operation belongs to. But it doesn't seem possible. I tried the following:
var edm = WebApiConfig.GetOdataEdmModel();
var operation = edm.SchemaElements.First(x => (x as IEdmOperation)?.Name == "GetRecentCustomers") as IEdmOperation;
var boundTo = operation.FindParameter("bindingParameter");
var matchingEntitySets = edm.EntityContainer.EntitySets()
.Where(x => x.Type.FullTypeName() == boundTo.Type.Definition.FullTypeName())
The problem is that matchingEntitySets can have more than one result. The reason is that the OData model is built this way:
var builder = new ODataConventionModelBuilder();
Is the answer simply that OData doesn't support more than one entity set with the same model type? If that is the case why doesn't the builder protect against this?
Jan 30, 2020 06:54 AM|Yongqing Yu|LINK
According to your descriotion, I hope the following links can help you solve your issue:
Actions and Functions in OData v4 Using ASP.NET Web API 2.2
oData v4 - ordering outer entity on property in related one-to-many entities
Jan 31, 2020 06:46 PM|sheamus08|LINK
Thanks for the reply. However, those links talk about adding actions and entities.
I am trying to interrogate the EDM model so I can generate typescript bindings. However, I have an issue where via the EDM model I am unable to determine which endpoint an action belongs to, because I have two EntitySets with the same underlying Entity.
Get I get the data about the action it tells me the underlying type, but not the entity set which means I don't know which endpoint to call that action off of.