---
title: "LINQ Implementation on 3-tier application"  
description: "Language Integrated Query (LINQ), pronounced simply as 'link' is a is a component released within the .NET 3.5 Framework. It is one of the most powerf"  
author: "Gaurav Shukla"  
published: 2011-11-10  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/264/linq-implementation-on-3-tier-application  
category: "linq"  
tags: ["linq"]  
reading_time: 2 minutes  

---

# LINQ Implementation on 3-tier application

[Language Integrated](https://www.mindstick.com/forum/159866/what-are-the-advantages-of-using-linq-language-integrated-query-in-c-sharp) Query (LINQ), pronounced simply as 'link' is a is a component released within the .NET 3.5 Framework. It is one of the most powerful features of .NET 3.5. It [serves the purpose](https://answers.mindstick.com/qa/39406/the-preamble-of-the-indian-constitution-serves-the-purpose-of) of querying objects.\

##### Microsoft basically divides LINQ into three areas and that are give below.

\
=> LINQ to Object {Queries performed against the in-memory data}\
=> LINQ to ADO.Net\
* [LINQ to SQL](https://www.mindstick.com/articles/338528/how-to-use-linq-to-sql-select-query-using-c-sharp) (formerly DLinq) {Queries performed against the relation database only [Microsoft SQL](https://www.mindstick.com/forum/159597/my-sql-server-vs-microsoft-sql-server-which-one-better) Server Supported}\
* LINQ to DataSet {Supports queries by using ADO.NET data sets and [data tables](https://www.mindstick.com/forum/1216/full-outer-join-on-2-data-tables-with-a-list-of-columns)}\
* LINQ to Entities {Microsoft ORM solution} \
=> LINQ to [XML](https://www.mindstick.com/forum/145511/please-explain-json-vs-xml) (formerly XLinq) { Queries performed against the XML source} \

##### There are two main dll's:-

System.Data.Linq.dll\
System.Linq.dll\

##### Three namespace are:-

using System.Data.Linq.Mapping; {for creating entity model or entity class }\
using System.Data.Linq; {for fetching the records from database}\
using System.Linq; {for perform conditional operation like as "orderby, groupby, where, take etc.... }\

##### Linq features :-

Encapsulated the features of generics.\
Avoid [boxing and unboxing](https://www.mindstick.com/articles/167412/boxing-and-unboxing).\
Data is type safe.\
\
Example:- **([Add Reference](https://www.mindstick.com/forum/548/how-to-add-reference-to-system-web-optimization) System.Data.Linq)**\

##### DAL.cs

```
using System;using System.Data.Linq;public class DAL:DataContext{  public DAL(string sCon):base(sCon)    {    }}
```

##### BL.cs

\

```
using System;using System.Data.Linq.Mapping;[Table(Name="student_detail")]public class Student{  [Column(Name = "in_student_id", IsPrimaryKey = true)]  public int SID { get; set; }  [Column(Name = "nvc_student_name")]  public string SNAME { get; set; }  [Column(Name = "nvc_address")]  public string SADDRESS { get; set; }  [Column(Name = "nvc_contact")]  public string SCONTACT { get; set; }  [Column(Name = "nvc_email")]  public string SEMAIL { get; set; }}
```

##### Default.aspx.cs

\

```
protected void button_Click(object sender, EventArgs e)    {      DAL oDal = new DAL("Data Source=.(localhost);Initial Catalog=testing;Integrated Security=true;");      Table<Student> otStudent = oDal.GetTable<Student>();      gv.DataSource = otStudent;      gv.DataBind();    }
```

---

Original Source: https://www.mindstick.com/blog/264/linq-implementation-on-3-tier-application

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
