By looking at the IntelliTrace, it looks like the API is doing lots of ADO.NET calls (I wasn't expecting any, since this is just a cache clear).
I'm using Entity Framework and an IQueryable for binding ItemSource, here the full code:
private MainViewModel vm => (MainViewModel)DataContext;
private string _lastSortedColumn = "DateLastSaved";
private ListSortDirection _lastSortDirection = ListSortDirection.Descending;
private void DataPager_OnOnDemandLoading(object sender, OnDemandLoadingEventArgs args)
{
var pageData = _lastSortDirection == ListSortDirection.Ascending ?
vm.Presentations.OrderBy(_lastSortedColumn) :
vm.Presentations.OrderByDescending(_lastSortedColumn);
DataPager.LoadDynamicItems(args.StartIndex,
pageData.Skip(args.StartIndex).Take(args.PageSize));
}
private void PptDataGrid_OnSortColumnsChanging(object sender, GridSortColumnsChangingEventArgs e)
{
DataPager.PagedSource.ResetCache();
DataPager.PagedSource.ResetCacheForPage(DataPager.PageIndex);
if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace)
{
var sortDesc = e.AddedItems[0];
_lastSortedColumn = sortDesc.ColumnName;
_lastSortDirection = sortDesc.SortDirection;
DataPager.MoveToPage(DataPager.PageIndex);
}
}