QueryAttribute.ResultLimit Property

WCF RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Gets or sets the maximum number of results a query operation should return.

Namespace:  System.ServiceModel.DomainServices.Server
Assembly:  System.ServiceModel.DomainServices.Server (in System.ServiceModel.DomainServices.Server.dll)

public int ResultLimit { get; set; }

Property Value

Type: System.Int32
The maximum number of results a query operation should return. The default is 0, which means there is no limit.

Set ResultLimit to a value that is equal to or greater than the value you assign to either the LoadSize property or the PageSize property. Setting ResultLimit to a value that is less than LoadSize or PageSize can cause records to be missing in the results and inconsistent paging.

The following example shows the ResultLimit applied to a query method that restricts the number of invoice records that can be returned by the query to 20.

[Query(ResultLimit = 20)]
public IQueryable<InvoiceTable> GetInvoiceTables()
    return this.ObjectContext.InvoiceTables.OrderBy(o => o.Date).ThenBy(o => o.InvoiceID);

In the following XAML, results are rendered based on the query for invoice records. Note that values for LoadSize and PageSize are both correctly set to a value less than that set in the ResultLimit applied to the query.

<Grid x:Name="LayoutRoot">
    <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}">
        <StackPanel x:Name="ContentStackPanel">
            <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}" Text="Invoices"/>
            <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}" Text="Invoices - Simple View"/>
            <riaControls:DomainDataSource Name="domainDataSource1" AutoLoad="True" QueryName="GetInvoicesTablesQuery" LoadSize="10">
                    <riaControls:SortDescriptor PropertyPath="InvoiceID" Direction="Ascending"></riaControls:SortDescriptor>
                    <riaControls:SortDescriptor PropertyPath="Date" Direction="Ascending"></riaControls:SortDescriptor>
            <my:DataGrid ItemsSource="{Binding Data, ElementName=domainDataSource1}" />
            <my:DataPager PageSize="10" Source="{Binding Data, ElementName=domainDataSource1}" />