Skip to content

Cosmos: querying an entity with a nested owned collection throws #18265

Closed
@TeaBaerd

Description

@TeaBaerd

I have an item object that is an entity in an EF Core 3 DbContext that is pointing to a Cosmos Db. When I try to retrieve the record from the DbContext, I get the following exception:
An exception of type 'System.InvalidOperationException' occurred in System.Linq.Expressions.dll but was not handled in user code: 'When called from 'VisitLambda', rewriting a node of type 'System.Linq.Expressions.ParameterExpression' must return a non-null value of the same type. Alternatively, override 'VisitLambda' and change it to not visit children of this type.'

This error is only thrown when the Item's object owns many ItemImages and ItemImages Owns many ImageAttributes. The AddAsync command thows no error when this information is added to a CosmosDb store but it will error every time on retrieval.

Any attempt to do a FirstOrDefaultAsync or FindAsync results in the error.

Steps to reproduce

I have attached sample code in a repository using VS code and the Cosmos Emulator.
https://github.com/TeaBaerd/CosmosEfCoreOwnsManyOwnsMany

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions