QueryAttribute.ResultLimit Property

[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)

Syntax

'Declaration
Public Property ResultLimit As Integer
    Get
    Set
'Usage
Dim instance As QueryAttribute
Dim value As Integer

value = instance.ResultLimit

instance.ResultLimit = value
public int ResultLimit { get; set; }
public:
property int ResultLimit {
    int get ();
    void set (int value);
}
member ResultLimit : int with get, set
function get ResultLimit () : int
function set ResultLimit (value : int)

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.

Remarks

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.

Examples

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 Function GetInvoiceTables() As IQueryable(Of InvoiceTable)
            Return Me.ObjectContext.InvoiceTables.OrderBy(Function(o) o.[Date]).ThenBy(Function(o) o.InvoiceID)
        End Function
[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:DomainDataSource.DomainContext>
                    <ds:TestDomainContext></ds:TestDomainContext>
                </riaControls:DomainDataSource.DomainContext>
                <riaControls:DomainDataSource.SortDescriptors>
                    <riaControls:SortDescriptor PropertyPath="InvoiceID" Direction="Ascending"></riaControls:SortDescriptor>
                    <riaControls:SortDescriptor PropertyPath="Date" Direction="Ascending"></riaControls:SortDescriptor>
                </riaControls:DomainDataSource.SortDescriptors>
            </riaControls:DomainDataSource>
            <my:DataGrid ItemsSource="{Binding Data, ElementName=domainDataSource1}" />
            <my:DataPager PageSize="10" Source="{Binding Data, ElementName=domainDataSource1}" />
        </StackPanel>
    </ScrollViewer>
</Grid>

See Also

Reference

QueryAttribute Class

System.ServiceModel.DomainServices.Server Namespace