INTRODUCTION
Here I will introduce to you with the new concept of .NET 3.5 i.e. Many people have heard about LINQ but very few people know about LINQ.
I will post a series of examples of LINQ in my blog. To start with I will show you how to add LINQ datasource into the project.
EXAMPLE
Create one demo project. Create a database connection and connect to your database as shown in the below figure.
Then add the Linq to sql class file (.dbml file) in to the solution.
By default it will be placed in the App_Data folder as shown below.
Open .dbml file and drag & drop the tables from the server explorer in the .dbml file. The .dbml file will look something like this.
.dbml file is a Linq datasource file. The datasource file creates the tables’ column property by default when you drag the table in the .dbml file.
The property is defined in .designer.cs file as shown below.
The Linq datasource maps to your database and creates the property for the respective table columns which you have drag into the .dbml file.
Now create the context for your datasource which you will be using it in your code. For that create the instance of your connection and add it to your Context at the top of .aspx.cs file.
public static string conn = ConfigurationManager.ConnectionStrings[“SampleConnectionString”].ToString();
EmployeesDetailsDataContext DetailContext = new EmployeesDetailsDataContext(conn);
Now you can start with further coding work with linq.
In the next part I will show you how to insert data through Linq query.Access the following link for next part.