count in projection

Thread is closed for posting
2 posts, 0 answers
  1. Jay
    Jay avatar
    28 posts
    Member since:
    Apr 2006

    Posted 24 Sep 2009 Link to this post

    When I use the count method I see a warning that it's obsolete and that it should be moved into the projection so that the calculation is done on the server side.  What should that look like?

    Scope.Extent<Story>().Count(a => a.Publish); 

  2. Zoran
    Zoran avatar
    534 posts

    Posted 29 Sep 2009 Link to this post

    Hello Ben Friedman,

    We have made improvements in Linq regarding the types of queries that you reported. There are some old warnings left as the one you are getting. Therefore, the warning you are getting is an 'obsolete' one itself. We have removed the obsolete warnings so you will not see those in the next versions of OpenAccess. The query you are executing is pushed properly to the server. Before supporting such queries, the form of your query would have been like:
    var query = scope.Extent<Story>().Where(a=>a.Publish).Count(); 

    If you write it in this form, the warning you are getting should not be there anymore.

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top