Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAaron Selonke
10,323 PointsWhat was that!
Why do the groupings return { Status = Vulnerable, Sightings = System.Collections.G eneric.List`1[BirdWatcher.Sighting] }
when calling the Count(), what exactly is being counted?
1 Answer
Matthew Hill
7,799 PointsWhen the results of the first query are grouped by status, all of the sightings associated with that status are turned into a list. So if you have:
Endagered - 1 sighting Endagered - 3 sightings Endagered - 2 sightings
You end up with:
Endagered - 1 sighting, 3 sightings, 2 sightings
As for your second question. Remember that sighting is a class in and of itself. This means that in the bird class it is represented as a list of sightings. You therefore need to do a count on the list for each bird in the group, then sum those together.
Hope that makes sense! Matt