Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
Max Result Count
See Also
Programmer's Guide > OpenAccess ORM Classic (Old API) > Telerik OpenAccess ORM OQL Reference > OQL - Object Query Language > Max Result Count

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

The IQuery.MaxResultCount property can be used to limit the number of instances to be returned by query execution. This property can be used for performance optimizations, if not all instances matching the query are required. This method must be called before the query is compiled or executed as this setting changes the generated backend query.

Here is an example of how we can retrieve the first 10 results only by using the MaxResultCount.

C# Copy Code
IObjectScope scope =OpenAccessData.ObjectScopeProvider1.GetNewObjectScope();
string query = "SELECT * FROM OrderExtent";
IQuery querry = scope.GetOqlQuery(query);
querry.MaxResultCount = 10;
var result = scope.GetOqlQuery(querry).Execute();
foreach (OpenAccessData.Order ord in result)
{
Console.WriteLine(ord.Freight);
}
VB .NET Copy Code
Dim scope As IObjectScope = OpenAccessData.ObjectScopeProvider1.GetNewObjectScope()
Dim query As String = "SELECT * FROM OrderExtent"
Dim querry As IQuery = scope.GetOqlQuery(query)
querry.MaxResultCount = 10
Dim result As var = scope.GetOqlQuery(querry).Execute()
For Each ord As OpenAccessData.Order In result
 Console.WriteLine(ord.Freight)
Next

 

See Also