LINQ API

Language-Integrated Query (LINQ) is a powerful query language introduced with .Net 3.5 & Visual Studio 2008.

What is LINQ

Standard Query Operators

While using the LINQ API, we have two ways to implement them

  • Query
  • Method

Although syntax written in Query is converted in Method Syntax at compile time. Today we will look into some Query Operator to get familiar with LINQ API implementation.

For more detailed information about LINQ API visit

https://docs.microsoft.com/en-us/dotnet/standard/using-linq

Implementation

  1. Where
  • Query:
Where in Query Syntaxt
  • Method:
Where in Method Syntax

2. OfType

  • Query:
OfType in Query Syntax
  • Method:
OfType in Method Syntax

3. OrderBy

  • Query:
OrderBy in Query Syntax
  • Method:
OrderBy in Method Syntax

4. All

All Operator Implementation

5. Any

Any Operator Implementation

6. Count

Count Operator

7. Intersect

Intersect Operator

I have not imported System, System.Collections.Generic and System.Linq in the last couple of operators. But do write it, otherwise, it will throw compile-time error.

So, that’s some LINQ API implementation in C#. LINQ has been a great way to write code in a more concise, readable, and maintainability manner in C#.

If you are having any questions, leave a comment.

Also find me on Linkedin 😃 and Github 😅

Sankhadip Samanta

Software Developer | Blogger