QueryableExtensions.Include<T> Method (IQueryable<T>, String)

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

Specifies the related objects to include in the query results.

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

Syntax

'Declaration
<ExtensionAttribute> _
Public Shared Function Include(Of T) ( _
    source As IQueryable(Of T), _
    path As String _
) As IQueryable(Of T)
'Usage
Dim source As IQueryable(Of T)
Dim path As String 
Dim returnValue As IQueryable(Of T)

returnValue = source.Include(path)
public static IQueryable<T> Include<T>(
    this IQueryable<T> source,
    string path
)
[ExtensionAttribute]
public:
generic<typename T>
static IQueryable<T>^ Include(
    IQueryable<T>^ source, 
    String^ path
)
static member Include : 
        source:IQueryable<'T> * 
        path:string -> IQueryable<'T> 
JScript does not support generic types and methods.

Type Parameters

  • T
    The type of entity being queried.

Parameters

  • 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<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(v=vs.113) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.113).

Remarks

This extension method calls the Include(String) method of the source IQueryable<T> object, if such a method exists. If the source IQueryable<T> does not have a matching method, then this method does nothing. The ObjectQuery<T>, ObjectSet<TEntity>, DbQuery<TResult> and DbSet<TEntity> types all have an appropriate Include method to call. Paths are all-inclusive. For example, if an include call indicates 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<T>. Other instances of IQueryable<T> and the object context itself are not affected. Because the Include method returns the query object, you can call this method multiple times on an IQueryable<T> to specify multiple paths for the query.

See Also

Reference

QueryableExtensions Class

Include Overload

System.Data.Entity Namespace