dotnet / dotnet/EntityFramework.Docs

Demonstrate querying sub-types in EFCore - Inheritance article

Open
#3,134 0 comments 1 reaction 0 assignees View on GitHub
area-query
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

Perhaps it would be a good idea to include how one should query a DbSet of the base type, to get items of the sub-types using DbSet.OfType()

I was looking to employ this particular use case and reached EF Core - Inheritance quite easily, but couldn't figure out how I can query to get items of a particar Sub-Type without having to load all the items from the db and choose ones I wanted. Since that was clearly suspect I kept looking until I found the answer on Stack overflow.

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: a10898c5-abee-1843-cfff-b2707f8a079a
* Version Independent ID: d9399618-488e-20b1-f707-35a191b95cc1
* Content: [Inheritance - EF Core](https://docs.microsoft.com/en-us/ef/core/modeling/inheritance)
* Content Source: [entity-framework/core/modeling/inheritance.md](https://github.com/dotnet/EntityFramework.Docs/blob/master/entity-framework/core/modeling/inheritance.md)
* Product: **entity-framework**
* Technology: **entity-framework-core**
* GitHub Login: @AndriySvyryd
* Microsoft Alias: **avickers**

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.