-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Embedded $expand not returning the Navigation property in certain scenarios #2076
Comments
Had the same issue with implicit containment - no attribute, no entity set declaration. |
@saidinarts @isabekyan
The PR #2083 itself includes the sample project change to use your sample codes. For example i change to use EF from EF Core. FYI. Thanks. The response for your query (http://localhost:5000/odata/Customers(456)/CustomerReferrals?$expand=ReferredCustomer($expand=Phones($expand=Formatted))) looks like: {
"@odata.context": "http://localhost:5000/odata/$metadata#Customers(456)/CustomerReferrals(ReferredCustomer(Phones(Formatted())))",
"value": [
{
"ID": 18,
"CustomerID": 456,
"ReferredCustomerID": 8,
"ReferredCustomer": {
"ID": 456,
"Phones": [
{
"ID": 21,
"CustomerID": 456,
"Formatted": {
"CustomerPhoneNumberID": 17,
"FormattedNumber": "abc"
}
},
{
"ID": 22,
"CustomerID": 457,
"Formatted": {
"CustomerPhoneNumberID": 18,
"FormattedNumber": "abc"
}
}
]
}
},
{
"ID": 19,
"CustomerID": 456,
"ReferredCustomerID": 9,
"ReferredCustomer": {
"ID": 456,
"Phones": [
{
"ID": 21,
"CustomerID": 456,
"Formatted": {
"CustomerPhoneNumberID": 17,
"FormattedNumber": "abc"
}
},
{
"ID": 22,
"CustomerID": 457,
"Formatted": {
"CustomerPhoneNumberID": 18,
"FormattedNumber": "abc"
}
}
]
}
}
]
} |
Can I ask why the commit for this issue hasn't been merged yet? It looks like the fix was identified pretty quickly but this issue has been open for over a year. I still hit this fairly frequently and would love for the fix to be implemented. Thank you!!! |
In a specific scenario, where a [Contained] houses a EntitySet, an embedded navigational property two levels deep within said EntitySet will not be returned.
Assemblies affected
Microsoft.AspNet.OData lib 7.6.0
Reproduce steps
The following entities are defined:
The DbContext model builder has the following:
The OData model builder is as follows:
A defined route is established for CustomerReferrals from a Customer, and the following query is applied:
salesinventory/Customers(486)/CustomerReferrals?$expand=ReferredCustomer($expand=Phones($expand=Formatted))
Expected result
The Formatted entity is returned in the results.
Actual result
The Formatted entity is not returned. Everything is returned except the Formatted entity.
Additional detail
The breakdown seems to happen during the serialization of the OData resource. The actual underlining SQL call and the entities returned to the ODataResourceSerializer have the Formatted class, but it is dropped. This seems to be as the NavigationSource is null on the given ResourceContext for CustomerPhone.
The text was updated successfully, but these errors were encountered: