Paging - Load operation failed for query...

PROBLEM

When you use RadDataPager or the standard DataPager you might encounter an error similar to this:

System.ServiceModel.DomainServices.Client.DomainOperationException: Load operation failed for query 'GetOrder_Details_Extended'. The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'.

Telerik Silverlight DataGrid troubleshoot paging

The Entity Framework can’t work with unsorted collections because the Skip() and Take() extension method expects an OrderBy clause.

SOLUTION

Add an OrderBy clause in your query at server side or define a SortDescriptor in the DomainDataSource in XAML or in the code behind file.

public IQueryable<Order_Details_Extended> GetOrder_Details_Extendeds() 
{ 
    return this.ObjectContext.Order_Details_Extendeds.OrderBy(o => o.OrderID); 
} 

<riaControls:DomainDataSource AutoLoad="True"  
                            d:DesignData="{d:DesignInstance my:Order_Details_Extended, CreateList=true}"  
                            Height="0" 
                            Name="order_Details_ExtendedDomainDataSource"  
                            QueryName="GetOrder_Details_ExtendedsQuery" Width="0"> 
    <riaControls:DomainDataSource.DomainContext> 
        <my:NorthwindDomainContext /> 
    </riaControls:DomainDataSource.DomainContext> 
    <riaControls:DomainDataSource.SortDescriptors> 
        <riaControls:SortDescriptor PropertyPath="OrderID" /> 
    </riaControls:DomainDataSource.SortDescriptors> 
</riaControls:DomainDataSource> 

order_Details_ExtendedDomainDataSource.SortDescriptors.Add(new SortDescriptor("OrderID", ListSortDirection.Ascending)); 

See Also

In this article