Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup
7h 34mIntermediate2025-05-02
Authors

Walt Ritscher
Programmer, UI Designer, Staff Instructor at LinkedIn Learning

Learn-it Labs
Course details
In this comprehensive course, Walt Ritscher explores the dynamic capabilities of .NET Language Integrated Query (LINQ). Get an introduction to LINQ syntax and versatile operators that streamline data querying, manipulation, and transformation across various sources, such as in-memory objects, databases, and XML files. Discover how to efficiently manage collections with LINQ to Objects, access structured data through LINQ to Entities, and seamlessly navigate hierarchical data with LINQ to XML and LINQ to JSON. Learn advanced techniques like deferred execution and expression trees. Learn how LINQ empowers you to filter, order, group, and aggregate data with ease, ensuring clarity and maintainability in your code. Whether you're working with relational data sources, building data-driven applications, or handling diverse data formats, you'll benefit from mastering the expressive power and convenient integration with C# that LINQ offers.
Skills covered
LINQ.NETDatabase DevelopmentDatabase ManagementSoftware Development ToolsMicrosoftSoftware DevelopmentOne-Off
Concepts
0. Introduction
- 01 - Unlock the power of in-language queries
- 02 - How to get the most from this course
- 03 - Course roadmap - What you ll learn
- 04 - How to access the sample code on GitHub
1. The Spirit of LINQ
- 05 - Why LINQ The need for a query engine
- 06 - LINQ essentials - Key concepts and features
- 07 - Finding and using the example code
2. Working with LINQPad
- 08 - Why use LINQPad
- 09 - Getting started - A tour of LINQPad
- 10 - How to set LINQPad preferences
- 11 - Writing and running code in LINQPad
- 12 - Set a destination folder for course files
- 13 - How to debug code in LINQPad
- 14 - Exploring the expression editor
- 15 - Exploring the statements editor
- 16 - Format output using the Dump method
- 17 - Exploring the program editor
- 18 - How to run a subset of code
3. Quick Looks
- 19 - Quick look at a LINQ to Objects query
- 20 - Quick look at a LINQ to Entities query
- 21 - Quick look at a LINQ to XML query
4. Parts of a LINQ Query
- 22 - What sources can you query
- 23 - Introduction to the Enumerable class
- 24 - Using Enumerable static methods
- 25 - Using Enumerable extension methods
- 26 - Writing queries with expression syntax
- 27 - Revisiting queryable data sources
- 28 - Deferred execution - When does a query run
- 29 - Building execution pipelines in LINQ
- 30 - Mixing extension methods and query syntax
5. Generating Data Sequences
- 31 - Generating an empty sequence
- 32 - Using DefaultIfEmpty in LINQ
- 33 - How to use the Repeat method
- 34 - How to use the Range method
6. LINQ Basics
- 35 - The three types of query expressions
- 36 - Review query expression clauses
- 37 - Examples of query expressions
- 38 - Exploring the course .NET class libraries
- 39 - Querying .NET libraries in ASP.NET
- 40 - Working with .NET external libraries
- 41 - Using select to project into an .NET type
- 42 - Using select to project into an anonymous type
- 43 - Use expressions with select
- 44 - Indexing into another sequence
- 45 - Challenge - Write select expressions
- 46 - Solution - Write select expressions
7. Filtering Data
- 47 - Using the Where method
- 48 - Use logical operators with the Where method
- 49 - Exploring the OfType class definitions
- 50 - Use the OfType method
- 51 - Challenge - Filter results with Where
- 52 - Solution - Filter results with Where
8. Summarize and Analyze Data with Aggregates
- 53 - How aggregate operations work
- 54 - Basic aggregate operators - Sum, Average, Min, Max, Count
- 55 - Using lambdas in aggregate operations
- 56 - Specify which property to aggregate
- 57 - Create custom aggregate operations
- 58 - Reverse a sequence with a custom aggregate
9. Categorize Data with GroupBy
- 59 - Grouping data with the GroupBy method
- 60 - Creating groups with a query expression
- 61 - Transforming groups with an element selector
- 62 - Transforming groups with query expressions
- 63 - Renaming keys and values with a result selector
- 64 - Renaming keys values with query expressions
- 65 - Iterating over groups in LINQ
- 66 - Using multiple keys for grouping
- 67 - Flattening sequences with SelectMany
- 68 - Challenge - Group results by color values
- 69 - Solution - Group results by color values
10. Element Operations
- 70 - Using the First and Last methods
- 71 - How the FirstOrDefault method works
- 72 - Retrieving elements with ElementAt
- 73 - Using Single and SingleOrDefault
11. Perform Set Operations
- 74 - The Distinct method explained
- 75 - Understanding Cartesian product
- 76 - How the Intersect method works
- 77 - Using the Union method
- 78 - Filtering with the Except method
- 79 - Finding duplicate values in a sequence
12. Quantifying Data
- 80 - Explore the quantify operators
- 81 - Use the Any method to detect empty sequence
- 82 - Use the Any method to check if an element exists
- 83 - How the Contains method works
- 84 - Use the All method to check if all elements match
13. Partitioning Data
- 85 - Explore the Partition operators
- 86 - Using the Skip and Take operators
- 87 - Using Skip and Take with conditions
14. Extending LINQ
- 88 - Use LINQ in a .NET application
- 89 - Enhance queries with MoreLinq
- 90 - MoreLinq in action - Additional examples
15. Querying Databases
- 91 - Understand LINQ for databases
- 92 - A quick look at querying database data
- 93 - Change the database connection strings
- 94 - IQueryable and other DB types
- 95 - Install SQLite and EF core power tools
- 96 - Overview of the course databases
- 97 - Quick look at creating EF models
- 98 - How to use the custom DbContext
- 99 - Review the entity framework models
16. Databases and LINQPad
- 100 - Connect to included sample database
- 101 - Connect to another database
- 102 - Connect to an EF model in a .NET assembly
- 103 - View the database structures in LINQPad
17. Exploring Queryable Types
- 104 - Explore the relevant LINQ types
- 105 - Understand how DbContext works
- 106 - DbSet - The foundation of EF collections
- 107 - Using navigation properties in EF
- 108 - Add, update, and remove data in EF
- 109 - View the generated SQL in LINQPad
18. Interesting Queries
- 110 - Projection - Retrieve fewer columns
- 111 - Paging data with take and skip
- 112 - Use Find for faster key-based search
- 113 - Use EF navigation properties over joins
- 114 - Using the Contains method in queries
- 115 - Group query results with GroupBy
- 116 - Flatten child collections with SelectMany
- 117 - Filter records by date range
19. LINQ to DataSet
- 118 - ADO.NET and LINQ to DataSet
- 119 - Reference another query file
- 120 - Create and populate a DataSet
- 121 - Query a DataSet using AsEnumerable
- 122 - Access DataRow fields in a query
20. Understanding LINQ to XML
- 123 - Understand LINQ for XML
- 124 - Overview of .NET XML types
21. Loading XML Data
- 125 - XML data files used in this course
- 126 - Load XML data from a file
- 127 - Introduction to the XDocument class
- 128 - How XML namespaces affect queries
- 129 - Parse XML from a string
- 130 - Save an XML document
- 131 - Quick look at a LINQ to XML query
22. Working with Elements and Attributes
- 132 - The structure and data in the XML file
- 133 - Retrieve an element from XML
- 134 - Retrieve an attribute from XML
- 135 - Get elements with a namespace
- 136 - Get attributes with a namespace
- 137 - Retrieve a collection of elements
- 138 - Retrieve child elements from XML
- 139 - Use Descendants() to find child elements
- 140 - Retrieve attributes from XML
- 141 - Read values from elements and attributes
23. Editing XML Values
- 142 - Change element and attribute values
- 143 - Issues with modifying element values
- 144 - Use SetElementValue to add, remove, and modify child elements
24. XML Query Operators
- 145 - Use Query syntax to work with elements
- 146 - Query element values in XML
- 147 - Query attributes in XML
- 148 - Project data into an anonymous type
- 149 - Filter by attribute value with Where
- 150 - Use Where to compare values
- 151 - Perform aggregate queries in XML
- 152 - Sort query results with OrderBy
- 153 - Find empty elements and blank values
- 154 - Group XML data with GroupBy
- 155 - Challenge - Create a custom string output
- 156 - Solution - Create a custom string output
- 157 - Challenge - Filter elements with no content
- 158 - Solution - Filter elements with no content
- 159 - Challenge - Filter results for invalid values
- 160 - Solution - Filter results for invalid values
25. Introduction to LINQ to JSON
- 161 - Basic JSON query techniques
- 162 - Load data from a JSON file
- 163 - Query JSON with type projection
- 164 - Group JSON data with GroupBy
26. Continuing Your Journey
- 165 - More examples from the course
- 166 - Next steps in your LINQ journey