Javatpoint Logo
Javatpoint Logo

LINQ to ADO.Net

LINQ to ADO.Net means using the LINQ queries on the objects in the ADO.Net. The LINQ to ADO.Net gives us a chance to write the LINQ Queries on Enumerable object in ADO.Net and the LINQ to ADO.Net is having the three types of LINQ technologies available. These are LINQ to Dataset, LINQ to SQL and LINQ to Entities.

Syntax of LINQ to ADO.Net

Here is the syntax of LINQ to ADO.Net objects.

In the above syntax, we have written the LINQ queries on the ADO.NET dataset object "ds" to get the required data.

LINQ to ADO.NET Example

Here we will see how to use LINQ to ADO.NET with the example for that we will create one new web application and make the connection with the SQL SERVER and write the queries on ADO.NET object (dataset) using LINQ to display the data in grid view.

Here first, we will create one new table "EmployeeDetails" in the database for that we will execute the following query in our database and insert some dummy data to show it in the application.

Now we will create a new web application for that Go to File->Select New->Select Project, as shown below.

LINQ Crud

After selecting the new project, a popup will open in that we have to choose asp.net empty Web Application and give the name as LINQ to ADO.NET and click ok to create a new web application.

Now we will add the web page to the application for that we have to the right click on the application-> Select Add->Select Web Form->Give name as "Default.aspx" and click the ok button, it will create a new page in the application.

Now open the "Default.aspx" page and write the code as shown below.

Now open the code behind the file and write the code as shown below:

In the above example, we used the ADO.NET dataset object and write the LINQ query on the dataset object to get the details from the dataset where Gender is equal to "Female". Now we will run the application and see the output.

OUTPUT

LINQ Crud
Next TopicLINQ to DataSet




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA