IQueryable 接口

定义

提供对未指定数据类型的特定数据源的查询进行计算的功能。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:在 MSDN 博客上构建 IQueryable 提供程序。For more information about how to create your own LINQ provider, see LINQ: Building an IQueryable Provider on MSDN Blogs.

属性

ElementType

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

Expression

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

Provider

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

方法

GetEnumerator()

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

(继承自 IEnumerable)

扩展方法

Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable)

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

AsQueryable(IEnumerable)

IEnumerable 转换为 IQueryableConverts an IEnumerable to an IQueryable.

Cast<TResult>(IQueryable)

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

OfType<TResult>(IQueryable)

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

适用于

另请参阅