From the course: .NET Essentials: Working with LINQ

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

Combine extension methods and query expressions

Combine extension methods and query expressions - .NET Tutorial

From the course: .NET Essentials: Working with LINQ

Combine extension methods and query expressions

- [Tutor] Whether you prefer to use query expressions or to use the extension methods. There are possible ways where you can mix the two of them together. And that's what we'll look at in this video. I'll start by looking at something in the Microsoft documentation. It says that the query syntax or what I've been calling query expression and the method syntax, which I've been calling the extension method syntax are semantically identical, which means it doesn't matter which one you use. You get the same results. Lets say here that some people find query syntax simpler and easy to read. So those people, if you're in that camp, you're going to want to use the query expression syntax everywhere. But you can't. There are some queries that can only be expressed with method calls. So let's take a look at some examples. We're starting here with a list of string colors. I've got a query expression here that gets all…

Contents