We've created a pager control that feeds a DataGrid a dynamic number of records instead of an entire table. It fetches records based on the page it's on and the number of records to display per page using the Skip and Take methods.
We're seeing some interesting behavior after a record in a page is marked as deleted. At that point, the pager will attempt to refresh itself and fetch the contents using the Skip and Take methods again. For some reason though, the query will sometimes incorrectly return 0 results.
I've been able to reproduce this behavior without the pager:
var random = new Random();
var count = EntityManager.Consultants.Count();
var skippedAndTaken =
EntityManager.Consultants.OrderBy(x => x.ConstId).Skip(count - 40).Take(20).ToList();
var randomEntity = skippedAndTaken.Skip(random.Next(20)).Take(1);
randomEntity.FirstOrDefault().EntityAspect.Delete();
var skippedAndTakenAgain =
EntityManager.Consultants.OrderBy(x => x.ConstId).Skip(count - 40).Take(20).ToList();
The skippedAndTakenAgain variable never contains any records when I run this code. This issue appears to happen frequently toward the 'end' of the table (in the example I'm skipping all but the last 40 records and then taking 20).
I've run similar code using Entity Framework and it works correctly.
Has anyone else seen this issue? Perhaps its an issue with caching or something?
Thanks!
Adam