LINQ Flashcards
What is a list?
A list is similar to an array but provides additional functionality, such as dynamic resizing.
What is LINQ?
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.
What is a LINQ provider?
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.
What are the two LINQ approaches?
One uses an SQL-like syntax, and the other uses method-call syntax.
What would filtering an array of integers with LINQ look like?
How does a LINQ query begin?
A LINQ query begins with a from clause, which specifies a range variable (value) and the data source to query (values).
What is the range variable?
The range variable represents each item in the data source, much like the control variable in a foreach statement.
What depicts which elements are selected?
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.
What determines what value appears in the results?
The select clause determines what value appears in the results.
How do you sort the query results?
The orderby clause sorts the query results in whatever order you choose.
What is the Interface IEnumerable<t>?</t>
How would you use LINQ to filter through an array of employee objects?
What will LINQs Any method return?
Returns true if there is at least one element and false if there are no elements.
What will LINQs First method return?
The first methos returns the first element in the result.
What will LINQs Count method return?
The count method of the query result returns the number of elements in the results.