Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ShadowMourne:
- var result = db.Students
- .Join(db.Students, s1 => s1.FacultyID, s2 => s2.FacultyID, (s1, s2) => new
- {
- LastName1 = s1.LastName,
- LastName2 = s2.LastName,
- ID1 = s1.ID,
- ID2 = s2.ID
- }).Where(y => y.ID1 != y.ID2 &&
- !db.Students
- .Join(db.Enrollments, s => s.ID, e => e.StudentID, (s, e) => new
- {
- e.CourseID,
- s.LastName,
- s.ID
- })
- .Join(db.Courses, c => c.CourseID, e => e.CourseID, (c, e) => new
- {
- c.CourseID,
- c.LastName,
- c.ID
- }).Where(x => x.ID == y.ID1)
- .Except(
- db.Students
- .Join(db.Enrollments, s => s.ID, e => e.StudentID, (s, e) => new
- {
- e.CourseID,
- s.LastName,
- s.ID
- })
- .Join(db.Courses, c => c.CourseID, e => e.CourseID, (c, e) => new
- {
- c.CourseID,
- c.LastName,
- c.ID
- }).Where(x => x.ID == y.ID2)
- ).Any()
- &&
- !db.Students
- .Join(db.Enrollments, s => s.ID, e => e.StudentID, (s, e) => new
- {
- e.CourseID,
- s.LastName,
- s.ID
- })
- .Join(db.Courses, c => c.CourseID, e => e.CourseID, (c, e) => new
- {
- c.CourseID,
- c.LastName,
- c.ID
- }).Where(x => x.ID == y.ID2)
- .Except(
- db.Students
- .Join(db.Enrollments, s => s.ID, e => e.StudentID, (s, e) => new
- {
- e.CourseID,
- s.LastName,
- s.ID
- })
- .Join(db.Courses, c => c.CourseID, e => e.CourseID, (c, e) => new
- {
- c.CourseID,
- c.LastName,
- c.ID
- }).Where(x => x.ID == y.ID1)
- ).Any()
- )
- .Select(x => new StudentViewModel
- {
- LastName1 = x.LastName1,
- LastName2 = x.LastName2
- })
- .ToList();
- result.ForEach(x => resultString += string.Concat(x.LastName1, x.LastName2));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement