Linq 101 Samples

3 posts, 0 answers
  1. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 17 Oct 2011 Link to this post

    Hi.

    I'm testing the 101 Linq samples and found one of them not working as expected.

    The test is 'Group By/Having' - 'GroupBy with Conditional Count' (or LinqToOpenAccessGroupBy07)

    The function should only count discontinued products, but counts all instead. Exact same result as LinqToOpenAccessGroupBy06.

    The linq code is as follows:
    public object LinqToOpenAccessGroupBy07()
    {
        var q = from p in context.Products
                group p by p.Category.CategoryID into g
                select new
                {
                    g.Key,
                    NumProducts = g.Count(p => p.Discontinued)
                };
     
        return q.ToList();
    }

    Thanks

    Pål
  2. Thomas
    Admin
    Thomas avatar
    590 posts

    Posted 18 Oct 2011 Link to this post

    Hi Pål,

    yes, this was indeed an issue; thanks for pointing this out. I've fixed this, and the next version (to be released mid of november) will contain the needed bits.

    All the best,
    Thomas
    the Telerik team

    Check out the latest stable build of Telerik OpenAccess ORM. Download it and benefit from our new Project Templates.

  3. DevCraft banner
  4. Pål
    Pål avatar
    53 posts
    Member since:
    Sep 2012

    Posted 18 Oct 2011 Link to this post

    That's great. Thanks

    Pål
Back to Top