Marek
Marek
CC#
Created by Marek on 7/28/2023 in #help
Need help with finding one option in VS
10 replies
CC#
Created by Marek on 7/24/2023 in #help
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
5 replies