Skip to content
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

OData+EF on inherited back-navigations #679

Closed
raffaeler opened this issue Aug 11, 2016 · 1 comment
Closed

OData+EF on inherited back-navigations #679

raffaeler opened this issue Aug 11, 2016 · 1 comment

Comments

@raffaeler
Copy link

This is the same issue reported here: https://entityframework.codeplex.com/workitem/2903

We have troubles using OData queries on a service based on EntityFramework.
The problem arises when we try to expand inherited back-navigation properties.
In attachment you can find a minimal example which reproduces the problem.

We have entities in the following hierarchy:
Base-->Derived-->DerivedDerived-->DerivedDerivedDerived
A back-navigation is declared on "Base" and queried on all four entity-types just to find that it only works on "Base" and "DerivedDerivedDerived" (i.e. only the least and most extended types).

The queries we tried are:
[...]/odata/Base?$expand=BackNav
[...]/odata/Derived?$expand=BackNav
[...]/odata/DerivedDerived?$expand=BackNav
[...]/odata/DerivedDerivedDerived?$expand=BackNav

Only cases 1 and 4 are working.

Cases 2 and 3 throw exception:
{ "error":{ "code":"","message":"An error has occurred.","innererror":{ "message":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; odata.metadata=minimal'.","type":"System.InvalidOperationException","stacktrace":"","internalexception":{ "message":"An error occurred while preparing the command definition. See the inner exception for details.","type":"System.Data.Entity.Core.EntityCommandCompilationException","stacktrace":" at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)\r\n at ...

OdataTest.zip

@Lingxi-Li
Copy link
Contributor

I noticed the use of the System.Web.OData namespace. Should investigate from the WebApi.OData level. Forwarded to OData/WebApi#792.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants