dotnet / dotnet/efcore

Cosmos: Use ReadItem when a concrete discriminator is manually specified in the predicate

Open
#34,195 0 comments 0 reactions 0 assignees View on GitHub
area-cosmos area-query
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

When the discriminator is part of the id property (this is no longer the default), we currently don't use ReadItem when a base type is being queried; this is because we don't know what the actual concrete of the type in the database is, so we can't construct its id property for ReadItem.

However, if the user explicitly specifies a concrete discriminator, either via `.Where(b => b.Discriminator == "Blog")` or via `context.Blogs.Where(b => b.GetType() == typeof(Blog))`, we could use ReadItem as we know exactly what we're looking for. The tricky thing there, is that there will still be the EF-injected WHERE c["Discriminator"] IN ("Blog", "SpecialBlog"), which we would need to know to ignore because of the more restrictive user comparison. This can be done, but isn't trivial...

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.