Share via


DbQuery<TResult>.Include 方法

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

指定要包括在查询结果中的相关对象。

命名空间:  System.Data.Entity.Infrastructure
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
Public Overridable Function Include ( _
    path As String _
) As DbQuery(Of TResult)
用法
Dim instance As DbQuery 
Dim path As String 
Dim returnValue As DbQuery(Of TResult)

returnValue = instance.Include(path)
public virtual DbQuery<TResult> Include(
    string path
)
public:
virtual DbQuery<TResult>^ Include(
    String^ path
)
abstract Include : 
        path:string -> DbQuery<'TResult> 
override Include : 
        path:string -> DbQuery<'TResult> 
public function Include(
    path : String
) : DbQuery<TResult>

参数

  • path
    类型:System.String
    要在查询结果中返回的相关对象列表(以点号分隔)。

返回值

类型:System.Data.Entity.Infrastructure.DbQuery<TResult>
一个新的 DbQuery<TResult>,它具有定义的查询路径。

备注

路径是完全内包含的。 例如,如果一个包含调用指示 Include("Orders.OrderLines"),则不仅包含 OrderLines,而且包含 Orders。 在调用 Include 方法时,查询路径仅在 DbQuery&amp;lt;T&amp;gt; 的返回实例上有效。 不影响 DbQuery&amp;lt;T&amp;gt; 的其他实例和对象上下文本身。 因为 Include 方法返回查询对象,所以可以对一个 DbQuery&amp;lt;T&amp;gt; 多次调用此方法,从而为查询指定多个路径。

请参阅

参考

DbQuery<TResult> 类

System.Data.Entity.Infrastructure 命名空间