Cosmos: Selecting complex properties (object or collections mapped as "OwnsOne" and "OwnsMany") makes the query return the entire document #27440
Labels
area-cosmos
area-query
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-enhancement
Milestone
I'm using Microsoft.EntityFrameworkCore.Cosmos 6.0.1 to perform queries against a Cosmos DB, but the problem I'm facing is that whenever I include in the
Select
any property that is either an object or a collection/array (mapped as "OwnsOne" and "OwnsMany"), instead of querying only the selected properties, it actually selects the entire document for EF to be able to select the complex/collection property.Code sample
Entities
Entity type configuration
Queries sample and Results
Query sample 1) Selecting only simple properties
Query sample:
Result:
Note that only the
c["id"]
andc["identifierNumber"]
were selected, as expected.Query sample 2) Selecting a complex object property (city)
Query sample:
Result:
In this case, the entire document is being selected (represented in the result as
c
), which shouldn't happen. If I copy and past this query on Azure Portal Cosmos Data Explorer, I can see it is indeed returning the entire document:Query sample 3) Selecting a collection/array property (subjects)
Query sample:
Result:
The same behavior happening when selecting a complex object is also happening with a collection property:
Provider and version information
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.Cosmos 6.0.1
Target framework: .NET 6.0
Operating system: Windows
IDE: Visual Studio Professional 2022
The text was updated successfully, but these errors were encountered: