欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

linq中如何在join中指定多个条件 博客分类: C# .NET linq equals 

程序员文章站 2024-02-05 17:36:34
...

貌似只能使用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();


            }

        }
相关标签: linq equals