nqLi Flashcards
What is LINQ?
language integrated query
A tool for filtering a set of data
eg, fundamental types (arrays, lists, collections)
as well as SQL DBs, XML, and .NET collections
lambda pattern
consists of:
- input parameters
- lambda operator
- expression
(input parameters) => expression
Predicate?
- test case
- this type of delegate that gets evaluated to true or false
How would you select all numbers > 90
int[] scores = new int[] { 97, 92, 81, 60 };
IEnumerable scoreQuery = from score in scores where score > 90 select score;
Note this will not actually run until scoreQuery is used elsewhere, such as in a for loop
What are LINQ queries converted to at compile time?
Standard Query Operator method calls according to the rules set forth in the C# specification
Count and Max must be used with what syntax?
Method Syntax
The query expression contains what three clauses?
from
where
select
Can a single LINQ query retrieve data from a SQL database, and produce an XML stream as output?
Yes
What methods can you use to force immediate execution of any query and cache its results?
ToList()
ToArray()
When you call a delegate in another function, do you use braces on the delegate?
No
partitioning operator?
deal with finding and extracting a subset of objects
what is a function’s signature?
its type and its parameters
What are anonymous types?
when the type is configured at compile time
a way to not have to think about what type of data this is (int, array, string, etc)
var
What is the join operator?
Correlates the elements of two sequences based on matching keys
What are aggregates?
Analysis operations on a data set
sum, count, average