Home / DeveloperSection / Blogs / LINQ Implementation on 3-tier application

LINQ Implementation on 3-tier application

Gaurav Shukla8081 10-Nov-2011
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 powerful features of .NET 3.5. It serves the purpose 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 (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
       * LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
       * LINQ to Entities {Microsoft ORM solution}
    => LINQ to XML (formerly XLinq) { Queries performed against the XML source}
There are two main dll's:-
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.
Data is type safe.

Example:- (Add Reference System.Data.Linq)
using System;
using System.Data.Linq;
public class DAL:DataContext
  public DAL(string sCon):base(sCon)

using System;
using System.Data.Linq.Mapping;
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; }

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;

Updated 18-Sep-2014

Leave Comment


Liked By