通过


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[]

分析时应位于范围内的可选查询参数集。

返回

与应用 ORDER BYSKIP 的原始实例等效的新ObjectQuery<T>实例。

例外

任何参数都是 null

keys 是空字符串。

-或-

count 是空字符串。

示例

本示例在跳过查询结果中的前三个对象后获取五 Product 个对象,排序依据 Product.ListPrice

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 使用。 使用TopSkip,它类似于子句的 ORDER BYLIMIT 语句。

适用于

另请参阅