This is a comprehensive course on a technology called Language Integrated Query (LINQ). LINQ is a core part of .NET that is responsible for helping us iterate through, filter, search, transform and manipulate collections, be it local objects (arrays, lists, etc.) or remote objects (e.g., databases).
This course covers:
This is a comprehensive course on a technology called Language Integrated Query (LINQ). LINQ is a core part of .NET that is responsible for helping us iterate through, filter, search, transform and manipulate collections, be it local objects (arrays, lists, etc.) or remote objects (e.g., databases).
This course covers:
A look at what we'll see in this course as a whole.
An overview of the topics we are going to cover in this section.
A discussion of LINQ operators and how they are used; we also discuss the two types of execution (immediate vs. deferred) and, in the case of deferred, discuss streaming vs. non-streaming operators.
LINQ operates on two key interfaces. One of the two interfaces is IEnumerable<T>. In this lecture we discuss this interface (as well as the related IEnumerator<T>) and look at some of their aspects. We also discuss how to implement the interface for your own class.
So... what does IEnumerable<T> look like, and how do you implement it for your own types?
LINQPad is a fantastic tool, specifically designed for learning LINQ. Best of all, it's free! Download and install it right now, we'll be using it throughout the entire course!
Static Enumerable methods that help us generate sequences.
A summary of what we've learned in this section.
An overview of what we are going to look at, and a discussion of immediate vs. deferred query operators.
A small reminder regarding the naming of sample files.
Operations for converting a sequence to something else:
Projection operations (also called mapping) simply takes each element and processes it, yielding something else. If that something else is a collection, you might need SelectMany() to flatten the sequence.
Filtering lets you only keep the sequence elements you need and throw away the rest.
Learn to order data and perform partial ordering. Also we learn how to reverse a string!
Putting data into groups by a specified key.
Operations on algebraic sets. Reminder: duplicate elements are ignored!
Quantifier operations are very simple:
Skip and Take lets us take skip or take only a part of a sequence (e.g., only the first 10 elements). The While() variants only perform the skipping/taking while the elements satisfy some condition.
Join operations are useful for associating elements from different sequences. They are also reasonably difficult to understand, so we'll take it slow.
Two things here. One, we'll see SequenceEqual, the useful LINQ operator for comparing the contents of collections. And how do you test collections for equality? What about testing collection contents while ignoring the order of elements?
Simple operations for getting a first or last element, for getting the one-and-only element in the collection (assuming there's only one) or just getting the element at the specified position.
Joining two LINQ sequences together is easy. But what about prepending values to the start of the sequence?
Aggregation operations collapse a sequence to a single value. Typical examples are the calculation of the number of elements, the sum or average of a numeric sequence.
A summary of all the LINQ operators that we've met in this section of the course.
An overview of what we are going to discuss in this section.
The magic of converting LINQ queries to SQL database queries is made possible by expression trees.
Just like IEnumerable<T>, IQueryable<T> provides a set of LINQ operators, but it's designed for querying databases and a remote sources. As a result, the operators take Expression<> instead if Func<>.
Time to put IQueryable<T> to use with LINQ by querying a database using LINQ to Entities.
Entity Framework provides additional LINQ operators that end with Async. What can they be used for?
A summary of all the things we've learned in this section.
An overview of lectures in this section.
AsParallel() turns an IEnumerable<T> into a ParallelQuery<T>
PLINQ takes cancellation tokens and throws either AggregateException or OperationCancelledException.
Do you want results as quickly as possible? Or should PLINQ cluster results together and return them in batches?
The LINQ Aggregate() function has a special PLINQ overload.
A summary of the features available in Parallel LINQ.
An overview of the things we'll encounter in this section. N.b. this section is also the place where user-requested topics will appear. If you see that something's missing, request it and I'll try to record and post a video on it!
LINQ to XML isn't specifically about applying LINQ... more about having an OOP representation of XML. But yes, you can also use LINQ if you want to.
ReSharper and Rider provide code analysis and context actions on LINQ queries. Just don't try to turn every loop into a LINQ expression - you might not enjoy the results!
What's that, you want more LINQ? Oh, alright then. MoreLINQ is a library that provides a few more LINQ-style operators.
A summary of this entire course. Thanks for watching!
OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.
Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.
Find this site helpful? Tell a friend about us.
We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.
Your purchases help us maintain our catalog and keep our servers humming without ads.
Thank you for supporting OpenCourser.