Replies: 1 comment
-
I've done more digging and discovered I was missing navigation properties at the entity set level. Revised, working code is once again attached for reference. That said, expansion-related behavioral challenges remain. I'm currently operating under the assumption that use of the EnableQuery attribute provides path of least resistance to the expansion challenge, but its presence generates runtime exceptions. Consider the following controller method with the attribute applied: [EnableQuery(MaxExpansionDepth = 10)] Invocation results in the following exception: The query specified in the URI is not valid. Could not find a property named 'Items' on type 'Microsoft.AspNetCore.OData.Formatter.Value.IEdmEntityObject'. The exception only occurs when the EnableQuery attribute is present. With it removed all requests process without issue, minus the expansion issue, obviously. I've stepped through the OData Lib and observed behavior within Microsoft.OData.UriParser's SelectExpandBinder class. The GenerateExpandItem method contained therein is unable to resolve properties for the dynamically generated models (IEdmEntityObject) returned from my data source. My data source returns in the following manner: `public class EntityDataSource : IDataSource
I am going to create an issue from this discussion and would greatly appreciate feedback. In an effort to reach more subject matter experts, I also posted to Stack Overflow (https://stackoverflow.com/questions/74964391/odata-dynamic-model-self-referencing-navigation-property-max-level-expansion). |
Beta Was this translation helpful? Give feedback.
-
Hello! I'm hoping someone out there is able to assist with an issue I'm currently facing. I have a scenario in which my EDM model is dynamic and contains a self-referencing navigation property. Source code is attached and based upon a sample project in this repo (https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataDynamicModel).
If my request explicitly expands to a desired depth, the response payload is correct, per the following:
http://localhost:4527/odata/ns/Items?$expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items))))
How might I go about expanding N levels since depth won't be known in a real world scenario? Numerous attempts haven't worked and I'm a bit puzzled, to say the least. Here's a recent attempt:
http://localhost:4527/odata/ns/Items?$expand=Detail,Items($levels=max;$expand=Detail,Items)
I greatly appreciate any insight and/or assistance!
ODataDynamicModel.zip
Beta Was this translation helpful? Give feedback.
All reactions