I have the following LINQ statement in VB:
Dim query As List(Of RepresentativeCase)
query = (From w In Me.RepresentativeCases
Where w.Active = True
Group w By w.PublicSubType, w.LawArea Into g = Group
Where g.Count(Function(x) x.PublicSubType.Distinct.Count) >= 100
Select g.First()
).ToList()
I am trying to convert into C# and having trouble. I got the following but it doesn't compile:
List<RepresentativeCase> query = (
from w in this.RepresentativeCases
where w.Active == true
group w by new { w.PublicSubType, w.LawArea} into g
let PublicSubType = g.Key.PublicSubType
let LawArea = g.Key.LawArea
where g.Count(x => x.PublicSubType.Distinct().Count()) > 100 // breaks here
select g.First()).ToList();
The where g.Count(x => x.PublicSubType.Distinct().Count()) > 100
line won't compile. Additionally, I am confused by the Into g = Group
in the VB sample - not clear what it does.
What am I missing?