ObjectQuery<T>.Skip(String, String, ObjectParameter[]) 方法

定义

按指定条件对查询结果进行排序并跳过指定数目的结果。

public:
 System::Data::Objects::ObjectQuery<T> ^ Skip(System::String ^ keys, System::String ^ count, ... cli::array <System::Data::Objects::ObjectParameter ^> ^ parameters);
public System.Data.Objects.ObjectQuery<T> Skip (string keys, string count, params System.Data.Objects.ObjectParameter[] parameters);
member this.Skip : string * string * System.Data.Objects.ObjectParameter[] -> System.Data.Objects.ObjectQuery<'T>
Public Function Skip (keys As String, count As String, ParamArray parameters As ObjectParameter()) As ObjectQuery(Of T)

参数

keys
String

作为结果排序依据的键列。

count
String

要跳过的结果数。 它可以是常量或参数引用。

parameters
ObjectParameter[]

在分析时应在作用域内的一组可选查询参数。

返回

一个新 ObjectQuery<T> 实例,等效于同时应用了 ORDER BYSKIP 的原始实例。

例外

任何参数为 null

keys 是一个空字符串。

- 或 -

count 是一个空字符串。

示例

此示例在跳过查询结果中的前三个对象(按 Product.ListPrice排序)后获取五Product个对象。

using (AdventureWorksEntities context =
    new AdventureWorksEntities())
{
    // Define the parameters used to define the "page" of returned data.
    int skipValue = 3;
    int limitValue = 5;

    // Define a query that returns a "page" or the full
    // Product data using the Skip and Top methods.
    // When Top() follows Skip(), it acts like the LIMIT statement.
    ObjectQuery<Product> query = context.Products
        .Skip("it.ListPrice", "@skip",
                new ObjectParameter("skip", skipValue))
        .Top("@limit", new ObjectParameter("limit", limitValue));

    // Iterate through the page of Product items.
    foreach (Product result in query)
        Console.WriteLine("ID: {0}; Name: {1}",
        result.ProductID, result.Name);
}

注解

Skip 方法不能在 Top 方法之后使用。 在 之后Skip使用 Top 时,它的函数类似于 子句的 ORDER BYLIMIT 语句。

适用于

另请参阅