Skip to content

LINQ

IT Notes → C# @ December 22, 2020

  • Structured type-safe queries over local object collections (any collection implementing IEnumerable<>,) and remote data sources.
  • Uses Enumerable class and Queryable class.
  • Sequences and elements.
  • Take, Skip, and Reverse.
  • FirstOrDefault, LastOrDefault, SingleOrDefault, or ElementAtOrDefault.
  • Aggregation operators: Count, Min, Max, and Average.
  • Contains, Any, All, and SequenceEquals.
  • Concat, Union, Intersect, Except.
  • Deferred or lazy evaluation.
  • Lazy execution defeated by element operators, aggregation operators, and quantifiers and also conversion operators: ToArray, ToList, ToDictionary, ToLookup.
  • Chaining query operators.
  • Query syntax or query comprehension syntax gives advantage of (1) let clauses for introducing new variables (2) Multiple generators (SelectMany) or Join or GroupJoin equivalent followed by an outer iteration variable reference.
  • Following into clause, the previous iteration variable is out of scope.
  • Cast, OfType.