Compatible with:

The ThenInclude feature is used to indicate to the ORM that a related property of a previously Included property should be returned with a query result.


Below is a specification that loads a Company entity along with its collection of Stores, then each Store’s collection of Products.

public class CompanyByIdWithStoresAndProducts : Specification<Company>, ISingleResultSpecification
  public CompanyByIdWithStoresAndProducts(int id)
    Query.Where(company => company.Id == id)
      .Include(x => x.Stores)
        .ThenInclude(x => x.Products)