This documentation is archived and is not being maintained.
ObjectQuery<T>::Top Method
Visual Studio 2010
Limits the query results to a specified number of items.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
Parameters
- count
- Type: System::String
The number of items in the results as a string.
- parameters
- Type: array<System.Data.Objects::ObjectParameter>
An optional set of query parameters that should be in scope when parsing.
Return Value
Type: System.Data.Objects::ObjectQuery<T>A new ObjectQuery<T> instance that is equivalent to the original instance with TOP applied.
| Exception | Condition |
|---|---|
| ArgumentNullException | count is nullptr. |
| ArgumentException | count is an empty string. |
These examples are based on the Adventure Works Sales Model.
This example creates a new ObjectQuery<T> that contains the first two results of the existing query.
This example gets five Product objects after skipping the first three in the query result, sorted by Product.ListPrice. Top is used instead of LIMIT for paging.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: