-
Notifications
You must be signed in to change notification settings - Fork 1
Day 03 LINQ Deep Dive
Kobi Hari edited this page Sep 17, 2020
·
1 revision
Fun With LINQ | Deep Dive into the features of LINQ |
- We have seen how to load CSV data files into an enumerable of data entities using LINQ
- We have used the basic operators
Select
,Where
,OrderBy
andTake
to create some basic queries - We saw how to use the query syntax with keywords such as
from
,select
,orderby
,where
and how they map to the fluent api extension methods
- We have seen how to use the
Aggregate
operator as a general way to produce a scalar value out of an enumerable - We have seen how to use the most basic variation of
Aggregate
to sum or find the max in a collection of items - We have seen how to use a seed and an accumulator to carry value between items of a collection
- We have seen how to use the most explicit version of
Aggregate
to finally convert the accumulator to the output result
- We have defined the term
Second order enumerable
as an enumerable of enumerables. - We have seen various ways to convert a first order enumerable to a second order enumerable:
GroupBy
,GroupJoin
,ToLookup
- We talked about the
IGrouping
interface- Extends the
IEnumerable
interface - Adds a
Key
property - Is a result of grouping methods
- Extends the
- We talked about how to convert second order enumerables back to flat enumerables by using the
SelectMany
operator
- We talked about the data structure generators in LINQ
ToArray
,ToList
,ToHashSet
- We have seen how to create a Mapping using
ToDictionary
- We have sen how to create a One-To-Many mapping using
ToLookup
and how to use the result
- We have seen a brief introduction to working with entity framework to access rational database data
- We have seen the most basic way to configure an EF database locally on Sql Server Express
- We saw that each table in the database is exposed using the
IQueryable
interface. - We noticed that this interface has its own set of LINQ operators
- We saw how to log the database activity to see the SQL generated from our LINQ queries
- We understood the the
IQueryable
Operators work with Expression Trees instead of delegates and compile them to SQL.
- We have done a bried investigation of expression trees
- We have seen the hierarchical nature of expression trees where each expression is composed of other expressions.
- We saw that the compiler knows how to initialize expression trees when assigned to a variable or to method parameter
- We saw how to compile an expression tree into a delegate and invoke it
- We saw a demonstration that the language query is actually compiled to a set of calls to extension methods
- The
select
keyword is translated to a call toSelect
extension method - The
where
keyword is translated to a call toWhere
extension method - the
orderby
keyword is translated to calls toOrderBy
,OrderByDescending
,ThenBy
,ThenByDescending
depends on how you use it - multiple
from
is translated to calls toSelectMany
- The
- We saw that if we create our own generic interface and implement the correct set of extension methods, we can run them using the query syntax.