Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Include(T) Method (IQueryable(T), String)

DbExtensions.Include(T) Method (IQueryable(T), String)

Entity Framework 5.0

Specifies the related objects to include in the query results.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

JScript does not support generic types and methods.

Type Parameters


The type of the entity being queried.


Type: System.Linq.IQueryable(T)

The source IQueryable on which to call Include.

Type: System.String

The dot-separated list of related objects to return in the query results.

Return Value

Type: System.Linq.IQueryable(T)
A new IQueryable of T with the defined query path.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable(T). When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936 or https://msdn.microsoft.com/en-us/library/bb383977.

Paths are all-inclusive. For example, if you pass “Orders.OrderLines” to the Include method (as in the following example: Include("Orders.OrderLines")), not only will OrderLines be included, but also Orders. When you call the Include method, the query path is only valid on the returned instance of the IQueryable of T. Other instances of IQueryable of T and the context itself are not affected. You can call this method multiple times on an IQueryable of T to specify multiple paths for the query.

© 2015 Microsoft