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 個 物件,並依 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,它會像 子句的 LIMIT 語句一 ORDER BY 樣運作。

適用於

另請參閱