Include
Compatible with:
The Include
feature is used to indicate to the ORM that a related navigation property should be returned along with the base record being queried. It is used to expand the amount of related data being returned with an entity, providing eager loading of related data.
Note: Lazy-loading is not recommended in web-based .NET applications.
Example
Below is a specification that loads a Company entity along with its collection of Stores.
public class CompanyByIdWithStores : Specification<Company>, ISingleResultSpecification
{
public CompanyByIdWithStores(int id)
{
Query.Where(company => company.Id == id)
.Include(x => x.Stores)
}
}