9. Groups Flashcards

1
Q

What does the LINQ GroupBy method do?

A

Groups the elements of a sequence.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you group by elements in a LINQ query expression?

A

By using the group and the by keywords.

eg. group x by x.Field

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the first two parameters that the GroupBy method takes (apart from the source)?

A
  1. Key Selector

2. Element Selector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the elementSelector parameter used for in a GroupBy method call?

A

Determining the return type of each element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you define a new variable inside a LINQ query expression?

A

By using the let keyword.

eg. let x = new {y.Name};

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the resultSelector parameter used for in a GroupBy method call?

A

Determining the data structure to be returned.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you use a result selector in a LINQ GroupBy query expression?

A

By using the into keyword after the group/by clause to define a variable that you use in a select clause to determine the return type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the keySelector parameter used for in a GroupBy method call?

A

Determining what value to group the sequence by. This value also becomes the key of each group element.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the SelectMany extension method do?

A

It flattens a sequence by allowing us to work with nested sequences.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly