public ActionResult Edit(int id)
        {
            using (DataContext db = new DataContext(ConfigurationManager.ConnectionStrings["sqlConnection"].ConnectionString))
            {
                IQueryable<ClassInformation> result = from c in db.GetTable<TClass>()
                                                      join t in db.GetTable<TTeacher>()
                                                      on new { id = c.ID, id1 = c.ID } 
                                                      equals new { id = t.ClassID, id1 = id }
                                                      select new ClassInformation { ID = c.ID, ClassID = t.ClassID, Name = c.Name, TeacherName = t.Name, Address = t.Address, Phone = t.Phone, Email = t.Email };
                ClassInformation k = result.Single();
                ViewData["K"] = k;
                return View();


            }

        }

 
借助于匿名类型:其实和解决按多条件分组的思路是一样的。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-10-05
  • 2021-09-07
  • 2021-09-13
  • 2022-12-23
猜你喜欢
  • 2022-03-07
  • 2021-10-13
  • 2022-12-23
  • 2022-01-13
  • 2021-07-31
  • 2021-09-21
相关资源
相似解决方案