-
Notifications
You must be signed in to change notification settings - Fork 163
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
Incomplete JSON output is returned when querying navigation property that has at least one complex property. #760
Comments
It is related to this PR: OData/odata.net#2552 |
@xuzhg , thanks for the reference,. |
We just released 7.13.0 ODL. But, it seems this version doesn't fix this issue. |
@xuzhg , Thanks for the update. Do you know if the problem is in odata.net library or its in AspNetOData core ? |
So far, I think it's from odata.net lib. The problem is that we want to 'calculate' a path for each sub-complex property. Because complex property could contain navigation property, we should need that path to 'calculate' the context path for navigation property again, even though we don't know whether the complex does have navigation property or not. OData/odata.net#2552 fixes the problem for the containment navigation property. I'd like to spend time understanding the complex property. |
Hi, I have same issue in .net 6 and odata 8.0.12 I have this object public class TelefonoDescrittivo public class Uffici2
in my Model declare: when in call my bonded function in the controller https://localhost:7146/odata/landingpageimmobili/Ufficio controller and ufficio return type "UfficiExt" with complex data i receive this exception. Microsoft.OData.ODataException: The type 'FastHomeDB.Models.UfficiExt' does not inherit from and is not a base type of 'FastHomeDB.Models.LandingPageImmobili'. The type of 'KeySegments' must be related to the Type of the EntitySet. Same issue was present in old version odata.net OData/odata.net#2092 |
Incomplete JSON output is returned when querying navigation property that has at least one complex property.
To reproduce the problem use ODataDynamicModel sample.
Now run this query :
http://localhost:4527/odata/mydatasource/Products(1)/DetailInfo
Note that output is truncated and does not include complex property of DetailInfo :
{"@odata.context":"http://localhost:4527/odata/mydatasource/$metadata#Products/ns.DetailInfo/$entity","ID":88,"Title":"abc_detailinfo" <no results after this>
I see this exception in debug:
_Microsoft.OData.ODataException
HResult=0x80131509
Message=The type 'ns.DetailInfo' does not inherit from and is not a base type of 'ns.Product'. The type of 'KeySegments' must be related to the Type of the EntitySet.
Source=Microsoft.OData.Core
StackTrace:
at Microsoft.OData.UriParser.ExceptionUtil.ThrowIfTypesUnrelated(IEdmType type, IEdmType secondType, String segmentName)
at Microsoft.OData.UriParser.KeySegment..ctor(IEnumerable
1 keys, IEdmEntityType edmType, IEdmNavigationSource navigationSource) at Microsoft.OData.UriParser.ODataPathExtensions.AddKeySegment(ODataPath path, IEnumerable
1 keys, IEdmEntityType edmType, IEdmNavigationSource navigationSource)at Microsoft.OData.ODataWriterCore.AppendEntitySetKeySegment(ODataPath odataPath, Boolean throwIfFail)
at Microsoft.OData.ODataWriterCore.EnterScope(WriterState newState, ODataItem item)
at Microsoft.OData.ODataWriterCore.WriteStartNestedResourceInfoImplementation(ODataNestedResourceInfo nestedResourceInfo)
at Microsoft.OData.ODataWriterCore.<>c__DisplayClass65_0.b__0()
at Microsoft.OData.TaskUtils.GetTaskForSynchronousOperation(Action synchronousOperation)
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.OData.Formatter.Serialization.ODataResourceSerializer.d__19.MoveNext() in D:\githubrepos\AspNetCoreOData\src\Microsoft.AspNetCore.OData\Formatter\Serialization\ODataResourceSerializer.cs:line 839
This exception was originally thrown at this call stack:
[External Code]
Microsoft.AspNetCore.OData.Formatter.Serialization.ODataResourceSerializer.WriteComplexPropertiesAsync(Microsoft.AspNetCore.OData.Formatter.Serialization.SelectExpandNode, Microsoft.AspNetCore.OData.Formatter.ResourceContext, Microsoft.OData.ODataWriter) in ODataResourceSerializer.cs_
Note: Complex type works when expanding the navigation property.
The text was updated successfully, but these errors were encountered: