---
title: "Language Integrated Query (LINQ)"  
description: "In this blog, I’m explaining the language integrated query and how to use it in our application.  LINQ stands for Language Integrated Query is a moder"  
author: "Sumit Kesarwani"  
published: 2013-12-19  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/612/language-integrated-query-linq  
category: "linq"  
tags: ["linq"]  
reading_time: 3 minutes  

---

# Language Integrated Query (LINQ)

In this blog, I’m explaining the [language integrated](https://www.mindstick.com/forum/159866/what-are-the-advantages-of-using-linq-language-integrated-query-in-c-sharp) query and how to use it in our [application](https://www.mindstick.com/articles/12824/calculator-application-in-android).\

LINQ stands for Language Integrated Query is a modern [Microsoft](https://www.mindstick.com/articles/12301/microsoft-is-trying-to-kill-passwords) technology. It provides the language level support mechanism to query all types of data.

Language-Integrated Query, or LINQ, is an [extension](https://www.mindstick.com/articles/22/extension-method) to the .NET [Framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) in version 3.5 that makes queries and set [operations](https://www.mindstick.com/blog/304985/how-does-devops-bridge-the-gap-between-development-and-operations-teams-like-git) first class citizens of .NET [languages](https://yourviews.mindstick.com/story/1463/some-oldest-languages-in-the-world-still-spoken) such as C#. It has been further defined as, "A set of general purpose standard query [operators](https://www.mindstick.com/articles/716/php-operators) that allow traversal, filter, and projection operations to be expressed in a direct yet declarative way in any .NET language

##### Example

##### Step 1:

Create a windows application and add a textbox and button and [datagridview](https://www.mindstick.com/articles/607/working-with-datagridview-in-vc-sharp) like this:

![Language Integrated Query (LINQ)](https://www.mindstick.com/blogs/3d2b7188-6833-4892-a6af-dbff3050f9ee/images/409ad9cf-b9d5-46fc-8a2e-57010dcf05eb.png)

##### Step 2:

Create a list and add data in it:

```
public class Student{public string Name { get; set; }public string Address { get; set; }public string CourseName { get; set; }public string ContactNumber { get; set; }}List<Student> students = new List<Student>(); students.Add(new Student { Name = "Mark", Address = "NewYork", CourseName = "M.B.A.", ContactNumber = "05127893628" });            students.Add(new Student { Name = "Steve", Address = "NewJersy", CourseName = "M.C.A.", ContactNumber = "0512734890" });            students.Add(new Student { Name = "John", Address = "LosAngeles", CourseName = "B.Tech", ContactNumber = "05127812345" });
```

##### Step 3:

Write the following linq query to get data in datagridview :

```
var query = from student in studentswhere student.Name.ToLower().Contains(searchText) ||                            student.Address.ToLower().Contains(searchText) ||                            student.CourseName.ToLower().Contains(searchText) ||                            student.ContactNumber.ToLower().Contains(searchText)                            select student;
```

The above linq query will give you data that matches with your entered

\

text.

##### Full Code:

```
public partial class frmStudentSearch : Form{  public class Student  {     public string Name { get; set; }     public string Address { get; set; }     public string CourseName { get; set; }     public string ContactNumber { get; set; }  }  List<Student> students = new List<Student>();  public frmStudentSearch()  {     InitializeComponent();  }private void Form1_Load(object sender, EventArgs e){     students.Add(new Student { Name = "Mark", Address = "NewYork", CourseName = "M.B.A.", ContactNumber = "05127893628" });            students.Add(new Student { Name = "Steve", Address = "NewJersy", CourseName = "M.C.A.", ContactNumber = "0512734890" });           students.Add(new Student { Name = "John", Address = "LosAngeles", CourseName = "B.Tech", ContactNumber = "05127812345" });}private void btnSearch_Click(object sender, EventArgs e){  string searchText = txtSearch.Text.Trim().ToLower();  if (!string.IsNullOrEmpty(searchText))  {    var query = from student in students                            where student.Name.ToLower().Contains(searchText) ||                            student.Address.ToLower().Contains(searchText) ||                            student.CourseName.ToLower().Contains(searchText) ||                            student.ContactNumber.ToLower().Contains(searchText)                            select student;dataGridStudents.DataSource = query.ToList();  }}}
```

##### Output

![Language Integrated Query (LINQ)](https://www.mindstick.com/blogs/3d2b7188-6833-4892-a6af-dbff3050f9ee/images/a39eac65-956e-462c-8ae4-f669e256cfe5.png)

It will search anything that exists in the list like if you type Name, Address, Course name or Contact Number.

---

Original Source: https://www.mindstick.com/blog/612/language-integrated-query-linq

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
