Learn the basics of working with Language-Integrated Query (LINQ), which allows developers to filter, sort, aggregate, and query data directly within C# code.
Overview
Syllabus
Introduction
- Welcome
- What you should know
- How to access the sample code on GitHub
- Why build a query engine in a programming language?
- Explore LINQ essential parts
- Why use LINQPad?
- Initial tour of LINQPad
- Set destination folder for course examples
- Explore the expression editor
- Explore the statements editor
- Show formatted output with the Dump method
- Explore the program editor
- Run a subset of code
- Implicit variable typing
- Anonymous types
- Object initializers
- Collection initializers
- Inline code with lambda expressions
- Extension methods
- More extension methods
- Generic types
- What sources are queryable?
- The Enumerable class
- Learn how to use the Enumerable static methods
- Learn how to use the Enumerable extension methods
- Learn how to use the Query Expression syntax
- What sources revisited
- Deferred execution: When does the query run?
- Combine methods with execution pipelines
- Combine extension methods and query expressions
- The Empty and DefaultIfEmpty methods
- The Repeat method
- The Range method
- The three types of query expressions
- Review query expression clauses
- Examples of three query expressions
- The select clause
- Learn how to use select to project into another type
- Select into anonymous type
- Learn how to use expressions with select
- Challenge: Write select expressions
- Solution: Write select expressions
- Index into another sequence
- The Where method
- Learn how to use logical operators with the Where method
- Explore the OfType class definitions
- The OfType method
- Challenge: Filter results with Where
- Solution: Filter results with Where
- Sum, Average, and other aggregates
- Create custom aggregates
- The GroupBy method
- GroupBy query expression
- GroupBy with ElementSelector
- GroupBy with ResultSelector
- Iterate over groups
- Combine two sequences
- Flatten sequence with SelectMany
- Challenge: Group results by color values
- Solution: Group results by color values
- First and Last methods
- The FirstOrDefault method
- The ElementAt method
- Single and SingleOrDefault methods
- The Distinct method
- The Intersect method
- The Union method
- The Except method
- Find duplicate values
- Learn how to use the Any method to detect empty sequence
- Learn how to use Any method to determine if element exists
- The Contains method
- The All method
- Skip and Take methods
- Conditional Skip and Take methods
- Learn how to use LINQ in a .NET application
- Learn how to use MoreLinq for extended query syntax
- Additional MoreLinq examples
- Next steps
Taught by
Walt Ritscher