Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * הרעיון של הפונקציה הזאת היא לאחד בין שלושת הטבלאות
- * Courses, ProfessorOfCourses, Persons
- * כדי שבסופו של דבר נוכל להראות את שם הקורס עם השם הפרטי
- * ושם המשפחה של הפרופסור
- */
- //אלו הטבלאות
- /*
- * Courses:
- * ID,name,points
- *
- * Persons:
- * ID, firstName, lastName, DOB
- *
- * ProfessorsOfCourses:
- * CourseID, ProfesorID
- *
- * StudentsInCourses:
- * CourseID, StudentID
- *
- */
- /*
- * ProfInCourses יכיל רשימה של זוגות:
- * PROF_ID, COURSE_NAME. זה בעצם חצי עבודה שרצינו.
- * עשינו ג'וין בין הטבלה Courses לבין הטבלה ProfessorOfCourses
- */
- var profInCourses = from prof in db.ProfessorsOfCourses //עבור כל שורה ב ProfessorsOfCourses
- join cour in db.Courses // עושים ג'וין עם הטבלה של קורסים
- on prof.CourseID equals cour.ID into profGroup // בוחרים על פי איזה שדה להשוות ומכניסים לטבלה זמנית
- from cour2 in profGroup //עוברים על כל השדות בטבלה
- select new { PROF_ID = prof.ProfesorID, COURSE_NAME = cour2.name }; //בוחרים אילו שדות נרצה להראות
- //פה עושים את אותו הדבר שעשינו למעלה
- //אבל עושים זאת עם הטבלאות Person ועם הטבלה שיצרנו למעלה profInCourses.
- var profNames = from prof in db.Persons
- join courProf in profInCourses
- on prof.ID equals courProf.PROF_ID into coursesGroup
- from cours in coursesGroup
- select new {
- PROF_NAME = prof.firstName,
- PROF_LAST = prof.lastName,
- COURSE_NAME = cours.COURSE_NAME
- };
- //מציגים את התוצאה ב DataGrid.
- dataShow.DataSource = profNames;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement