How to use SQL Query with LINQ


Add LINQ to SQL Class from Add New Item Template and name it TestDataClassesDataContext
Add Database table in to TestDataClassesDataContext
Create a  TestDataClassesDataContext object into default.aspx.cs  page

  TestDataClassesDataContext objDBContext = new TestDataClassesDataContext(ConfigurationManager.ConnectionStrings["TestConnectionString"].ToString());
 

//Bind Gridview using LINQ with Query
// User_Tbls is User_Table(DataBase table) class
var userdetails = from user in objDBContext.User_Tbls select user;

        GridView1.DataSource = userdetails;
        GridView1.DataBind();

Comments

Popular posts from this blog

Display multiple marker point on Google Map with same location or same Longitude,Latitude

Comparing cursor vs. WHILE loop performance

Implementing Zoom functionality in asp.net