LINQ Flashcards

1
Q

What is a list?

A

A list is similar to an array but provides additional functionality, such as dynamic resizing.

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

What is LINQ?

A

C#’s LINQ(Language-Integrated Query) capabilities allow you to write query expressions that retrieve information from a variety of data sources, not just databases.

LINQ to Objects can be used to filter arrays and Lists, selecting elements that satisfy a set of conditions.

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

What is a LINQ provider?

A

A LINQ provider is a set of classes that implement LINQ operations and enable programs to interact with data sources to perform tasks such as projecting, sorting, grouping and filtering elements.

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

What are the two LINQ approaches?

A

One uses an SQL-like syntax, and the other uses method-call syntax.

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

What would filtering an array of integers with LINQ look like?

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

How does a LINQ query begin?

A

A LINQ query begins with a from clause, which specifies a range variable (value) and the data source to query (values).

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

What is the range variable?

A

The range variable represents each item in the data source, much like the control variable in a foreach statement.

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

What depicts which elements are selected?

A

If the condition in the where clause evaluates to true, the element is selected.

A predicate is an expression that takes an element of a collection and returns true or false by testing a condition on that element.

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

What determines what value appears in the results?

A

The select clause determines what value appears in the results.

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

How do you sort the query results?

A

The orderby clause sorts the query results in whatever order you choose.

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

What is the Interface IEnumerable?

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

How would you use LINQ to filter through an array of employee objects?

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

What will LINQs Any method return?

A

Returns true if there is at least one element and false if there are no elements.

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

What will LINQs First method return?

A

The first methos returns the first element in the result.

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

What will LINQs Count method return?

A

The count method of the query result returns the number of elements in the results.

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

What will LINQs Select clause do?

A

The select clause can be userd to select a member of the range variable rather than the range variable itself.

17
Q

What will LINQs Distinct method return?

A

The distinct method removes duplicate elements, causing all elements in the result to be unique.

18
Q
A
19
Q

How would you use LINQ to query a list collection?

A

The same as an array.

20
Q

What does the let clause do?

A

It can be used to create a new range variable to store a temporary result for use later in the LINQ query

21
Q

When do LINQ querys execute?

A

LINQ uses deferrec execution - the query eexecutes only when you access the results, not when you define the query.