views:

251

answers:

1

Hi;

I am testing out RIA services. I put together a RIA Services library and built a custom DomainService (i.e. not an Entity Framework Domain Service). I am accessing the library from a silverlight app and all is working as expected. I can call the RIA service functions and get the results. I have an issue with Pagination. I cannot find anywhere a description of using Pagination on a RIA service that uses custom domainServices. My RIA Service is accessing a specialied DAL for access to data (and is not compatible with the Entity Frameework). What I have found was an indication to pass the pagination paramters (i.e. page, page size) to a RIA Service function. So I have done just that - created a RIA service function that takes additional parameters for Page [index] and Page size. I am testing using in Sivlerlight using a DataGrid and a DataPager. The RIA service with the pagination paramters is called (and returns data) and the DataGrid is populated. The problem I'm having is when I go to another page. What is occuring is the RIA service is called twice. The first time with the proper params (i.e. correct page index) then again with a page index of zero). I.E. always resets to first page. I don't undestant why this is occuring; I believe I put togehter everything properly (hopfully). The folliwing is the XAML script:

< riaControls:DomainDataSource Name="ddsScheduleTemplates"
LoadSize="20" QueryName="GetPagedScheduleTemplates" AutoLoad="True" >

                    <riaControls:DomainDataSource.DomainContext>
                        <ds:ScheduleEngineDomainContext/>
                    </riaControls:DomainDataSource.DomainContext>

                    <riaControls:DomainDataSource.QueryParameters>
                        <riaControls:Parameter ParameterName="UserLogonName" Value="admin" />
                        <riaControls:Parameter ParameterName="UserPassword" Value="admin" />
                        <riaControls:Parameter ParameterName="Page" Value="{Binding ElementName=dpScheduleTemplates, Path=PageIndex}" />
                        <riaControls:Parameter ParameterName="PageSize" Value="{Binding ElementName=dpScheduleTemplates, Path=PageSize}" />
                    </riaControls:DomainDataSource.QueryParameters>

                </riaControls:DomainDataSource>

                    <StackPanel>

                        <dg:DataGrid 
                            Name="ScheduleTemplatesGrid" 
                            MinHeight="100" 
                            MaxHeight="300"
                            IsReadOnly="True" 
                            ItemsSource="{Binding ElementName=ddsScheduleTemplates, Path=Data}"
                        />

                        <dg:DataPager 
                            x:Name="dpScheduleTemplates" 
                            PageSize="10"
                            Source="{Binding ElementName=ddsScheduleTemplates, Path=Data}"                                 
                            PageIndexChanged="dpScheduleTemplates_PageIndexChanged" 
                        />

                    </StackPanel>

I have modified the above script to call the general loading function (GetPagedScheduleTemplates - returns all records) and adjusted the QueryParameters list for the function. The DataGrid loads properly - and pagination works properly.

This confused me - it sort of looked like the DataPager required all data to be loaded in order for it to work properly - but I did a test where I loaded all data on paged request operation; (i.e. pagination properties setup and calling pagination version of RIA service function) but DataGrid still resets.

Note: I had read that the DataPager requires the return list to be ordered - so I did so - but did not affect operation - paging always reset to page 1 - the following is the return list from the RIA service function newList.ToArray().AsQueryable().OrderBy(x=>x.ScheduleTemplateID)

So; my question is - has anyone seen this behavior - or am I making a horrendous mistake - if so what am I doing wrong?

Peter

A: 

Ok -- well this took some investigation. I was not aware of some of the limitations of Ria Services and how communication occurs with the client. From what I've found out the pagination information is xfered to the ria service via linq based operations. I'm not too up on Ria services at this level but I've found someone who has done some nice work to put together a library that exposes the pagination information via a custom DomainService. The library is available at: http://riatodal.codeplex.com/

Info on who and how to use the library: ryanmwright.com/tag/ria-services

This library is meant for something more general but focuses on the pagination restrictions with the supplied Ria DomainServices from MS.

Peter

Peter