DbExtensions.Include<T> Method (IQueryable<T>, String)
Specifies the related objects to include in the query results.
Assembly: EntityFramework (in EntityFramework.dll)
public static IQueryable<T> Include<T>( this IQueryable<T> source, string path ) where T : class
The type of the entity being queried.
- Type: System.Linq.IQueryable<>
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 ValueType: System.Linq.IQueryable<>
A new IQueryable of T with the defined query path.
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable<>. 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(v=vs.103).aspx or http://msdn.microsoft.com/en-us/library/bb383977(v=vs.103).aspx.
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.