Using Query.ResultLimit with DomainDataSource
Server throttling is one the new features we introduced in our RC release. It lets you regulate the per request load on the server / DB by specifying maximum result limit on a query method using the QueryAttribute.ResultLimit property.
Here is how you can specify a result limit on a query method:-
1: [Query(ResultLimit=1000)]
2: public IQueryable<Customer> GetCustomers()
3: {
4: return this.ObjectContext.Customers;
5: }
The result limit query only applies to the top level entities, so the above query will result in returning 1000 top level entities. This limit will not apply to the included entities.
As you will notice, the ResultLimit will not be propagated to the client. Things get really interesting when you use DomainDataSource especially when you are using LoadSize and PageSize.
Keep the following in mind, if you are developing an application that happens to have a query limit and uses DomainDataSource on the client:-
- Choose the ResultLimit appropriately.
- Configure your client to pull data in chunks (DomainDataSource supports this through the LoadSize property).
- The load size should be less than or equal to your server query result limit.
- Do not have a page size that is greater than the result limit.
- It is good practice to have a LoadSize that is a multiple of PageSize.
Here is an example on how to specify LoadSize and PageSize on DomainDataSource
1: <riaControls:DomainDataSource
2: AutoLoad="True"
3: LoadSize="20"
4: PageSize="10"
5: Name="customerDataDomainDataSource"
6: QueryName="GetCustomersQuery"
7: Width="0">
8: <riaControls:DomainDataSource.DomainContext>
9: <my:CustomerContext/>
10: </riaControls:DomainDataSource.DomainContext>
11: </riaControls:DomainDataSource>
Cheers!
Comments
Anonymous
April 08, 2010
Dude, Your point 5 belies your example. PageSize="10" is not a multiple, i.e. mathematical product, of LoadSize="20". Shouldn't it be the other way around? Please, advise.Anonymous
April 09, 2010
Thanks !! corrected it.