Incomplete JSON output is returned when querying navigation property that has at least one complex property.
@xuzhg is already working on this.
Since Dec 6, 2022.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Incomplete JSON output is returned when querying navigation property that has at least one complex property.
To reproduce the problem use ODataDynamicModel sample.
- In MyDataSource.cs, add EdmComplexType property to DetailInfo entity.
- Add some value to this complex property in CreateDetailInfo()
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(IEnumerable1 keys, IEdmEntityType edmType, IEdmNavigationSource navigationSource)
at Microsoft.OData.UriParser.ODataPathExtensions.AddKeySegment(ODataPath path, IEnumerable1 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.