© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
4 replies
Marek

I need help with understanding the flow of LINQ query expressions

Hello, i'm starting to learn the LINQ language and i don't know if i got my understanding of the process of executing right. My "theory" on example below from official Microsoft documentation is this:
1. It splits students into a row of student
2. It groups every student by the Year property into studentGroups
3. It Selects new Anonymous type with Level and HighScore of the group
I'm sorry if i messed it up but thats the reason why I'm even creating this post.
My theory number two is that everything under from except select and let applies directly to from. I couldn't find which one of these theories is right if even any of them is :D
var queryGroupMax =
    from student in students
    group student by student.Year into studentGroup
    select new
    {
        Level = studentGroup.Key,
        HighestScore = (
            from student2 in studentGroup
            select student2.ExamScores.Average()
        ).Max()
    };
var queryGroupMax =
    from student in students
    group student by student.Year into studentGroup
    select new
    {
        Level = studentGroup.Key,
        HighestScore = (
            from student2 in studentGroup
            select student2.ExamScores.Average()
        ).Max()
    };

Thanks for your time,
Mark

PS: I get what it is doing and i do understand all the keywords just don't know the order of execution
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Need help with a linq query
C#CC# / help
3y ago
❔ Need help with a LINQ query
C#CC# / help
4y ago
❔ Help with linq query
C#CC# / help
4y ago
❔ LINQ expressions with "pipeline" pattern
C#CC# / help
3y ago