linq 多表查询

来源:互联网 发布:jenkins自动构建java 编辑:程序博客网 时间:2024/05/29 17:05

 int  name = Convert.ToInt32(textBox1.Text.Trim());
            DataClasses1DataContext db = new DataClasses1DataContext();
            var student = from content in db.tb_Student
                          join category in db.tb_chengji on
                          content.xuehao equals category.xuehao
                          where category.chengji== name

                          select new
                          {
                              name = content.name,
                              nianling = content.nianling,
                              chengji = category.chengji


                          };
            dataGridView1.DataSource = student;