views:

1492

answers:

3

I have a Silverlight 3 app with RIA Services and I'm running into an issue where my DataPager is only loading data for the initial loadsize and then no longer reloading. It brings up two pages of data (PageSize=10, LoadSize=20.) It is correctly showing 119 pages of data but when I navigate to page 3, nothing appears in my datagrid and dataforms.

This is my Domain Data Source:

<riaControls:DomainDataSource x:Name="_dds" QueryName="GetCaseLoads" AutoLoad="True" PageSize="10" LoadSize="20">
    <riaControls:DomainDataSource.DomainContext>
        <domain:FooContext />
    </riaControls:DomainDataSource.DomainContext>
</riaControls:DomainDataSource>

Here's the snippet for the DataPager:

<data:DataPager Source="{Binding Data, ElementName=_dds}" />

And here's the Domain Service query:

[RequiresAuthentication()]
public IQueryable<CaseLoad> GetCaseLoads()
{
    // Return all case loads
    return this.Context.CaseLoadSet;
}

It's pretty straightforward so I'm not sure what's missing. Any help would be appreciated;

+3  A: 

After spending way too much time trying to get this working I FINALLY figured out the problem, which I think is more of a bug with the RIA Services technology because I should have gotten some kind of warning message about this.

The simple fix is to order the collection being returned by GetCaseLoads(). I did it like this and it worked:

[RequiresAuthentication()]
public IQueryable<CaseLoad> GetCaseLoads()
{
    // Return all case loads
    return this.Context.CaseLoadSet.OrderBy(caseLoad=>caseLoad.fkUserId);
}

Amazing how much time solving this little problem took.

Nick Gotch
A: 

I had the same problem, I can see from the example given in the RIA Services Overview documentation that they are using LINQ to SQL instead of LINQ to EF - must be something with the difference between the two.

Thanks for posting the workaround, saved me many hours of faffing :)

Duncan Watts
A: 

Thanks a lot you rock man..thanks for saving time...Hey Microsoft guys please lookin to this problem man