IQueryable Interface


提供针对特定数据源(其中数据类型未指定)评估查询的功能。Provides functionality to evaluate queries against a specific data source wherein the type of the data is not specified.

public interface class IQueryable : System::Collections::IEnumerable
public interface IQueryable : System.Collections.IEnumerable
type IQueryable = interface
    interface IEnumerable
Public Interface IQueryable
Implements IEnumerable


IQueryable 接口旨在供查询提供程序实现。The IQueryable interface is intended for implementation by query providers. 它仅应由也实现 IQueryable<T>的提供程序实现。It is only supposed to be implemented by providers that also implement IQueryable<T>. 如果提供程序未实现 IQueryable<T>,则不能对提供程序的数据源使用标准查询运算符。If the provider does not also implement IQueryable<T>, the standard query operators cannot be used on the provider's data source.

IQueryable 接口继承了 IEnumerable 接口,因此,如果它表示一个查询,则可以枚举该查询的结果。The IQueryable interface inherits the IEnumerable interface so that if it represents a query, the results of that query can be enumerated. 枚举将导致执行与 IQueryable 的对象关联的表达式树。Enumeration causes the expression tree associated with an IQueryable object to be executed. "执行表达式树" 的定义特定于查询提供程序。The definition of "executing an expression tree" is specific to a query provider. 例如,它可能涉及将表达式树转换为基础数据源的相应查询语言。For example, it may involve translating the expression tree to an appropriate query language for the underlying data source. 调用 Execute 方法时,将执行不返回可枚举结果的查询。Queries that do not return enumerable results are executed when the Execute method is called.

有关如何创建自己的 LINQ 提供程序的详细信息,请参阅linq:生成 IQueryable 提供程序For more information about how to create your own LINQ provider, see LINQ: Building an IQueryable Provider.



获取在执行与 IQueryable 的此实例关联的表达式树时返回的元素的类型。Gets the type of the element(s) that are returned when the expression tree associated with this instance of IQueryable is executed.


获取与 IQueryable 的实例关联的表达式树。Gets the expression tree that is associated with the instance of IQueryable.


获取与此数据源相关联的查询提供程序。Gets the query provider that is associated with this data source.



返回循环访问集合的枚举器。Returns an enumerator that iterates through a collection.

(Inherited from IEnumerable)

Extension Methods


IEnumerable 的元素强制转换为指定的类型。Casts the elements of an IEnumerable to the specified type.


根据指定类型筛选 IEnumerable 的元素。Filters the elements of an IEnumerable based on a specified type.


启用查询的并行化。Enables parallelization of a query.


IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.


IQueryable 的元素转换为指定的类型。Converts the elements of an IQueryable to the specified type.


根据指定类型筛选 IQueryable 的元素。Filters the elements of an IQueryable based on a specified type.

Applies to

See also