2
使用'from'子句或'join'子句时加入多个表时有区别吗?返回的结果集是相同的。Linq to实体来自vs加入
在多对多的关系(包括结表)就拿三个表:学生,StudentCourses,课程:
var query = from student in context.Students
from studentcourse in student.StudentCourses
where studentcourse.CourseID == 4
select student;
var query = from student in context.Students
join studentcourse in context.StudentCourses
on student.StudentID equals studentcourse.StudentID
where studentcourse.CourseID == 4
select student;
- 要么他们是最好的做法?
- 表现?这个比那个好吗?我还没有机会到SQL Profiler中的任何一个。
我使用包括以下两个原因避免:
- 我需要条件包括往往不是,因此上述两种技术。
- 从我读过的内容,包括返回整个相关的表,可能是性能的征税。