Skip to content

Day 03 LINQ Deep Dive

Kobi Hari edited this page Oct 20, 2020 · 1 revision

Day 03 - Deep Dive into LINQ

Projects:

Fun With LINQ Deep Dive into the features of LINQ

The Idea behind LINQ

  • We have created extension methods on enumerables that create new enumerables - thus creating operators
  • We have passed delegates to the methods in order to allow them to be a lot more flexible
  • We made them even more flexible by converting them to generic methods so that they can run on any type of enumerables
  • We have examined the deferred nature of the operators

LINQ To Data Entities

  • 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 and Take 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

Second Order Operators

  • 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, ToLookup
  • We talked about the IGrouping interface
    • Extends the IEnumerable interface
    • Adds a Key property
    • Is a result of grouping methods
  • We talked about how to convert second order enumerables back to flat enumerables by using the SelectMany operator

Data Structure Operators

  • 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

Aggragation Operators

  • 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