From the course: C# Essential Training 2: Generics, Collections, and LINQ

Unlock the full course today

Join today to access over 24,700 courses taught by industry experts.

Querying collections with LINQ

Querying collections with LINQ

- [Instructor] Looking at this example, we can actually rewrite this in a slightly different way. Let's do a var, we'll just say fEmployees, equal. Now I can use from, I can say emp in employees, so I'm now using some integrated query language. You can see that from and in here are keywords. I can now say where, emp, and we can do the same thing we did before. ID is greater than two. Select, oops, I've got to properly case the ID there. Now we could do the same thing. We can select a new object. In fact, we could just copy and paste this. So now we can simply change this to fEmployees. We should see the same results. If you've done any querying of databases, for example, or other systems, a lot of these keywords, a lot of this structure is very similar. It's slightly different from, say, a SQL query where you'd start with the select first, then the from and the where. But it's the same kind of idea. So we set up that…

Contents