src/Shared/EntityFramework/Infrastructure/DbQuery`.cs
/// <summary>
///     Specifies the related objects to include in the query results and move in the Include chain to the TProperty.
/// </summary>
/// <remarks>
///     The path expression must be composed of simple property access expressions together with calls to Select for
///     composing additional includes after including a collection proprty.  Examples of possible include paths are:
///     To include a single reference: query.Include(e => e.Level1Reference)
///     To include a single collection: query.Include(e => e.Level1Collection)
///     To include a reference and then a reference one level down: query.Include(e => e.Level1Reference.Level2Reference)
///     To include a reference and then a collection one level down: query.Include(e => e.Level1Reference.Level2Collection)
///     To include a collection and then a reference one level down: query.Include(e => e.Level1Collection.Select(l1 =>
///     l1.Level2Reference))
///     To include a collection and then a collection one level down: query.Include(e => e.Level1Collection.Select(l1 =>
///     l1.Level2Collection))
///     To include a collection and then a reference one level down: query.Include(e => e.Level1Collection.Select(l1 =>
///     l1.Level2Reference))
///     To include a collection and then a collection one level down: query.Include(e => e.Level1Collection.Select(l1 =>
///     l1.Level2Collection))
///     To include a collection, a reference, and a reference two levels down: query.Include(e =>
///     e.Level1Collection.Select(l1 => l1.Level2Reference.Level3Reference))
///     To include a collection, a collection, and a reference two levels down: query.Include(e =>
///     e.Level1Collection.Select(l1 => l1.Level2Collection.Select(l2 => l2.Level3Reference)))
///     This extension method calls the Include(String) method of the source IQueryable object, if such a method exists.
///     If the source IQueryable does not have a matching method, then this method does nothing.
///     The Entity Framework ObjectQuery, ObjectSet, DbQuery, and DbSet types all have an appropriate Include method to
///     call.
///     When you call the Include method, the query path is only valid on the returned instance of the IQueryable&lt;T&gt;.
///     Other
///     instances of IQueryable&lt;T&gt; 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&lt;T&gt; to specify multiple paths for the
///     query.
/// </remarks>
/// <typeparam name="TProperty"> The type of navigation property being included. </typeparam>
/// <param name="path"> A lambda expression representing the path to include. </param>
/// <returns>
///     A new IncludeDbQuery&lt;TResult, TProperty&gt; with the defined query path.
/// </returns>
Specifies the related objects to include in the query results and move in the Include chain to the TProperty.
Specifies the related objects to include in the query results and move in the Include chain to the TProperty .
[SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
        [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")]
        public IncludeDbQuery<TResult, TProperty> Include<TProperty>(Expression<Func<TResult, TProperty>> path)
        {
            Check.NotNull(path, "path");
            string include;
            if (!DbHelpers.TryParsePath(path.Body, out include)
                || include == null)
            {
                throw new ArgumentException(Strings.DbExtensions_InvalidIncludePathExpression, "path");
            }
            var query = Include(include);
            return new IncludeDbQuery<TResult, TProperty>(query, include);
        }
[ SuppressMessage ( " " , " " ) ] [ SuppressMessage ( " " , " " ) ] public IncludeDbQuery < TResult , TProperty > Include < TProperty > ( Expression < Func < TResult , TProperty > > path ) { Check . NotNull ( path , " " ) ; string include ; if ( ! DbHelpers . TryParsePath ( path . Body , out include ) || include == null ) { throw new ArgumentException ( Strings . DbExtensions_InvalidIncludePathExpression , " " ) ; } var query = Include ( include ) ; return new IncludeDbQuery < TResult , TProperty > ( query , include ) ; }
Specifies the related objects to include in the query results and move in the Include chain to the TProperty.
Specifies the related objects to include in the query results and move in the Include chain to the TProperty .
A new IncludeDbQuery with the defined query path.
A new IncludeDbQuery with the defined query path .
path
Expression<Func<TResult, TProperty>>
A lambda expression representing the path to include.
A lambda expression representing the path to include .
remarks
The path expression must be composed of simple property access expressions together with calls to Select for
composing additional includes after including a collection proprty.  Examples of possible include paths are:
To include a single reference: query.Include(e => e.Level1Reference)
To include a single collection: query.Include(e => e.Level1Collection)
To include a reference and then a reference one level down: query.Include(e => e.Level1Reference.Level2Reference)
To include a reference and then a collection one level down: query.Include(e => e.Level1Reference.Level2Collection)
To include a collection and then a reference one level down: query.Include(e => e.Level1Collection.Select(l1 =>
l1.Level2Reference))
To include a collection and then a collection one level down: query.Include(e => e.Level1Collection.Select(l1 =>
l1.Level2Collection))
To include a collection and then a reference one level down: query.Include(e => e.Level1Collection.Select(l1 =>
l1.Level2Reference))
To include a collection and then a collection one level down: query.Include(e => e.Level1Collection.Select(l1 =>
l1.Level2Collection))
To include a collection, a reference, and a reference two levels down: query.Include(e =>
e.Level1Collection.Select(l1 => l1.Level2Reference.Level3Reference))
To include a collection, a collection, and a reference two levels down: query.Include(e =>
e.Level1Collection.Select(l1 => l1.Level2Collection.Select(l2 => l2.Level3Reference)))
This extension method calls the Include(String) method of the source IQueryable object, if such a method exists.
If the source IQueryable does not have a matching method, then this method does nothing.
The Entity Framework ObjectQuery, ObjectSet, DbQuery, and DbSet types all have an appropriate Include method to
call.
When you call the Include method, the query path is only valid on the returned instance of the IQueryable.
Other
instances of IQueryable 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 to specify multiple paths for the
query.
The path expression must be composed of simple property access expressions together with calls to Select for composing additional includes after including a collection proprty . Examples of possible include paths are : To include a single reference : query . Include ( e = > e . Level1Reference ) To include a single collection : query . Include ( e = > e . Level1Collection ) To include a reference and then a reference one level down : query . Include ( e = > e . Level1Reference . Level2Reference ) To include a reference and then a collection one level down : query . Include ( e = > e . Level1Reference . Level2Collection ) To include a collection and then a reference one level down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Reference )) To include a collection and then a collection one level down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Collection )) To include a collection and then a reference one level down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Reference )) To include a collection and then a collection one level down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Collection )) To include a collection a reference and a reference two levels down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Reference . Level3Reference )) To include a collection a collection and a reference two levels down : query . Include ( e = > e . Level1Collection . Select ( l1 = > l1 . Level2Collection . Select ( l2 = > l2 . Level3Reference ))) This extension method calls the Include ( String ) method of the source IQueryable object if such a method exists . If the source IQueryable does not have a matching method then this method does nothing . The Entity Framework ObjectQuery ObjectSet DbQuery and DbSet types all have an appropriate Include method to call . When you call the Include method the query path is only valid on the returned instance of the IQueryable . Other instances of IQueryable 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 to specify multiple paths for the query .
typeparam
The type of navigation property being included.
The type of navigation property being included .