Query Expressions used in LINQ

In this article , we will explore about Query Expressions used in Language-Integrated Query. LINQ simplifies the situation of learning different query languages. I hope this article will be useful to you.

Query Expressions of LINQ :


LINQ stands for Language-Integrated Query.There are mainly two types of query execution.
One is Deferred Execution and another is forcing immediate execution.
What is Deferred Execution?
In this type of execution, actual execution of the query is deferred until the developer iterates over the query variable in a for each statement.
Query variable does not contain any query results.
We can execute it whenever there is necessory.

What is Forcing immediate execution?
Aggregation functions can be performed by these type of queries over a range of source elements must first iterate over those elements.

Description of Query Expressions:

It uses declarative query syntax. We can write queries which are type safe.
Syntax is close to SQL like. It is very easy to write as well as understand.
Aggregate queries typically return a number instead of a collection.You cannot call aggregates against anonymous types.

Example :

//The program to find numbers in the given array which are greater than two

public void GetGreaterThanTwo()
int[] Set_Of_numbers = { 3,4,1,0 };

var greaterNumbers =
from n in Set_Of_numbers
where n > 2
select n;

Console.WriteLine("Output for numbers greater than two : ");
foreach (var xi in greaterNumbers)

In LINQ query , we are always working with different objects. A query is an expression which is used to retrive data from the datasource.
LINQ Queries are expressed in simple strings which are based on generic types.
For. e.g

IEnumerable StudentQuery =
from stud in students
where stud.Name == "Meenal"
select stud;

In this query , data is retireved for the student whose name is Meenal.


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: