ObjectQuery<T>.Skip(String, String, ObjectParameter[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
依指定的準則排序查詢結果,並略過指定的結果數目。
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 BY 和 SKIP 。
例外狀況
任何參數都是 null。
範例
此範例跳過查詢結果中前三個物件後,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使用。 當你使用 Top after Skip時,它就像子句的 ORDER BY 陳述一樣。