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
Post a Comment