dotnet / dotnet/EntityFramework.Docs

It's not clear how to include multiple collections beyond first level

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

Description

In the examples above, the following is clear
context.Blogs
.Include(blog => blog.Posts).ThenInclude(post => post.Tags).ThenInclude(tag => tag.TagInfo)
.Include(blog => blog.Contributors);
However, what if someone would like to include multiple post collections? For example, suppose a Post has Comments in addition to Tags. How do we also include post.Comments in the above example?

---
#### Document Details

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

* ID: d5f7a5f6-21f4-f4bf-39fd-36af12aa1277
* Version Independent ID: bd1c0b9f-39c8-61f9-d3aa-3420d5edb570
* Content: [EntityFrameworkQueryableExtensions.ThenInclude Method (Microsoft.EntityFrameworkCore)](https://docs.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.entityframeworkqueryableextensions.theninclude?f1url=https%3A%2F%2Fmsdn.microsoft.com%2Fquery%2Fdev16.query%3FappId%3DDev16IDEF1%26l%3DEN-US%26k%3Dk(Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ThenInclude%60%603);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv4.7.2);k(DevLang-csharp)%26rd%3Dtrue&view=efcore-3.0)
* Content Source: [dotnet/xml/Microsoft.EntityFrameworkCore/EntityFrameworkQueryableExtensions.xml](https://github.com/aspnet/EntityFramework.ApiDocs/blob/live/dotnet/xml/Microsoft.EntityFrameworkCore/EntityFrameworkQueryableExtensions.xml)
* Product: **ef-core-api**
* GitHub Login: @dotnet-bot
* Microsoft Alias: **divega**

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.