//DataContext类在System.Data.Linq命名空间中。
using System.Data.Linq;
//数据源
DataContext dc = new DataContext("data Source=192.168.0.66;database=LSS1;user id=sa;pwd=xit");
Table<User> users = dc.GetTable<User>();
//创建查询
int age = Convert.ToInt32(this.txtAge.Text.ToString());
var result = from user in users
where user.Age == age
select new { 序号 = user.UserID, 姓名 = user.UserName, 年龄 = user.Age };
//执行查询
this.GridView1.DataSource = result;
this.GridView1.DataBind();