IQueryable<Content>.Count(): unexpected result

Posted by Community Admin on 04-Aug-2018 16:47

IQueryable<Content>.Count(): unexpected result

All Replies

Posted by Community Admin on 26-Mar-2012 00:00

Hi,

I'm not sure whether this is a bug or not. Can anyone help?

var news = App.WorkWith().NewsItems().Publihed()
        .OrderByDescending(t => t.PublicationDate)
        .Get();
 
int count = news.Count(); // count = 1068
 
news = news.Take(5);
 
int count2 = news.Count(); // count2 = 1068 (expected = 5 or below)

This is with Sitefinity 4.3.
Thanks.

Edit: I tried the exact same thing with Entity Framework, and it works as expected. Is this an OpenAccess bug?

Posted by Community Admin on 29-Mar-2012 00:00

Hi Thomas,

Thank you for using our services. Although I did not find any bug logged about this issue, I have tried it on our latest officially supported version - Sitefinity 5.0, and the correct count is returned. For your convenience I'm attaching a sample video demonstrating the default behavior I'm observing.

Regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 29-Mar-2012 00:00

Hi Boyan,

Thanks for your answer. I'll try again when we update to Sitefinity 5.0 and report back (if I don't forget...). Meanwhile, as a workaround, I used ToArray().Length.

Posted by Community Admin on 12-Apr-2012 00:00

Confirmed as fixed in Sitefinity 5.0.

This thread is closed