ObjectQuery<T>.Skip(String, String, ObjectParameter[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Orders the query results by the specified criteria and skips a specified number of results.
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)
Parameters
- keys
- String
The key columns by which to order the results.
- count
- String
The number of results to skip. This must be either a constant or a parameter reference.
- parameters
- ObjectParameter[]
An optional set of query parameters that should be in scope when parsing.
Returns
A new ObjectQuery<T> instance that is equivalent to the original instance with both ORDER BY and SKIP applied.
Exceptions
Any argument is null
.
Examples
This example gets five Product
objects after skipping the first three in the query result, sorted by 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);
}
Remarks
The Skip method cannot be used after the Top method. When you use Top after Skip, it functions like the LIMIT statement of an ORDER BY
clause.