This question is locked. New answers and comments are not allowed.
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:
Thanks
Pål
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