New Posts New Posts RSS Feed: Issue with query using skip and take after an entity is marked as deleted
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Issue with query using skip and take after an entity is marked as deleted

 Post Reply Post Reply
Author
akukucka View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Jul-2010
Location: Rochester, NY
Posts: 11
Post Options Post Options   Quote akukucka Quote  Post ReplyReply Direct Link To This Post Topic: Issue with query using skip and take after an entity is marked as deleted
    Posted: 10-Sep-2010 at 6:29am
Thanks for the response!

I'm not convinced that the delete is taking no part in this behavior.  The skip/take scheme we're utilizing works great for every page we create until delete is introduced.

Also, say I delete a record from page 23 (of a total of 25 pages).  Upon refresh, the query for page 23 yields no results.  Page 24 may or may not yield any results, but page 25 (the last page) does.

QueryStrategy.DataSourceOnly does work for me in this situation IF I commit each delete (which I did not plan on doing).  But it would really be nice to utilize the cache whenever possible and speed things up for the user.

I really have reproduced this skip/take query in EF and it did return the correct results after a delete...
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 09-Sep-2010 at 3:04pm
The query is returning 0 results because you are running it against the cache and once it skips a x number of records, there is nothing left to take.
The "deleting" part takes no role in this behavior.
 
Try using DataSourceOnly QueryStrategy:
 
var skippedAndTakenAgain = EntityManager.Consultants
                                                              .With(QueryStrategy.DataSourceOnly)
                                                              .OrderBy(x => x.ConstId)
                                                              .Skip(count - 40)
                                                              .Take(20)
                                                              .ToList();
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 08-Sep-2010 at 9:47am
Hi Adam,
 
I'm investigating your issue and will follow up with you soon.
Back to Top
akukucka View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Jul-2010
Location: Rochester, NY
Posts: 11
Post Options Post Options   Quote akukucka Quote  Post ReplyReply Direct Link To This Post Posted: 08-Sep-2010 at 5:33am
Anyone???
Back to Top
akukucka View Drop Down
Newbie
Newbie
Avatar

Joined: 22-Jul-2010
Location: Rochester, NY
Posts: 11
Post Options Post Options   Quote akukucka Quote  Post ReplyReply Direct Link To This Post Posted: 03-Sep-2010 at 12:03pm
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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down