linq中如何在join中指定多个条件

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/gengyigang/article/details/84766138

貌似只能使用equals判断相等,大于小于怎么做呢?

 

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();


            }

        }
展开阅读全文

没有更多推荐了,返回首页