More in this section

Forums / Developing with Sitefinity / IQueryable<Content>.Count(): unexpected result

IQueryable&lt;Content&gt;.Count(): unexpected result

4 posts, 0 answered
  1. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    26 Mar 2012
    Link to this post
    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?
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    29 Mar 2012
    Link to this post
    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
  3. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    29 Mar 2012
    Link to this post
    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.
  4. Thomas
    Thomas avatar
    223 posts
    Registered:
    19 Jan 2011
    12 Apr 2012
    Link to this post
    Confirmed as fixed in Sitefinity 5.0.
4 posts, 0 answered