Export (0) Print
Expand All

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)

static member Include : 
        source:IQueryable<'T> * 
        path:string -> IQueryable<'T>  when 'T : not struct

Type Parameters

T

The type of the entity being queried.

Parameters

source
Type: System.Linq.IQueryable(T)

The source IQueryable on which to call Include.

path
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 http://msdn.microsoft.com/en-us/library/bb384936 or http://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.

Show:
© 2014 Microsoft