Closed briangardner closed 2 years ago
Duplicate of #16926 and #17957
Please see this too, it should be the same error https://github.com/dotnet/efcore/issues/23704
The thing I can't wrap my head around is how does $expand
make sense when we're talking about Cosmos DB? Presumably $expand
gets translated to either a Join
or an Include
which doesn't make sense as there are no joins in Cosmos DB (except inner joins).
The only logical way to handle this would be to generate a SelectMany
call which may not be what the user of the API expects.
I think folks who are using Cosmos DB with Odata need to disallow the usage of expand, or create an Expression
visitor which replaces any Join
's or Include
's with SelectMany
.
Well, the Expand
is the only way to get the testSubEntities
values in the response, correct? If you need those values, how would you get those?
I'm facing a similar problem with Microsoft.Restier and EF Core with CosmosDB.
@Mishu if the subtitles are in a different document, then getting them in the same query isn't supported on Cosmos (see #16920). If the subtitles are part of the document (i.e. they represent a JSON fragment inside it), then there's no need to include/expand them - they are already automatically fetched.
Expected Behavior
-Running OData query against EF Core Cosmos DB Provider with $expand would return OData result like this: GET https://localhost:5001/odata/TestEntities?$expand=TestSubEntities
Observed behavior: Exception with the following stack trace
Code to Reproduce the issue:
https://github.com/briangardner/CosmosOdata
Additional Commentary
OData $expand works when the entire result set is loaded into memory first using
.ToList().AsQueryable()
, but just returning the IQueryable directly from the DbSet throws the exception.Include provider and version information
EF Core version: 5.0.1 Database provider: Microsoft.EntityFrameworkCore.Cosmos Target framework: .Net Core 3.1 Operating system: Windows 10 IDE: Visual Studio 2019 Version 16.8.3