You might want to redo your EF entities. Right now you are saying that each course has multiple lecturers and a lecturer is either a professor or an assistant. But your course index view seems to indicate that each course should have one professor and multiple assistants.
You also are indicating that a lecturer can only be a professor or an assistant. I would first make sure that a professor of one course cannot be the assistant of another first. If that is the case then I would create a separate table (or entity) for professors and assistants.
Make each course have one professor and multiple assistants. On the other hand if professors can be assistants then you need to remove the professor designation from the lecturer and build it into the relationship to the courses by having each course have one lecturer that is the professor and a list of lecturers that are the assistants However if you want to continue with your current setup you should be able to populate your desired view with something like this var courseViews = from c in db. Courses select new CourseView() { CourseID = c.ID, ProfessorName = (from l in c.
Leturers where l. Is_Professor select l.Name).FirstOrDefault(), AssistantNames = (from l in c. Leturers where!l.
Is_Professor select l.Name).ToList() }.
You might want to redo your EF entities. Right now you are saying that each course has multiple lecturers and a lecturer is either a professor or an assistant. But your course index view seems to indicate that each course should have one professor and multiple assistants.
You also are indicating that a lecturer can only be a professor or an assistant. I would first make sure that a professor of one course cannot be the assistant of another first. If that is the case then I would create a separate table (or entity) for professors and assistants.
Make each course have one professor and multiple assistants. On the other hand if professors can be assistants then you need to remove the professor designation from the lecturer and build it into the relationship to the courses by having each course have one lecturer that is the professor and a list of lecturers that are the assistants. However if you want to continue with your current setup you should be able to populate your desired view with something like this var courseViews = from c in db.
Courses select new CourseView() { CourseID = c. ID, ProfessorName = (from l in c. Leturers where l.
Is_Professor select l. Name).FirstOrDefault(), AssistantNames = (from l in c. Leturers where!l.
Is_Professor select l. Name).ToList() }.
That FirstOrDefault will make a trouble. I would try Take(1) instead. – Ladislav Mrnka May 29 at 13:32 @Ladislav How so?
Does EF not handle FirstOrDefault? I personally have never tried it with EF. Also a Take would result in a IQueryable instead of a string.
– juharr May 29 at 13:36 It indeed handles FirstOrDefault but FirstOrDefault triggers the query execution. There was another related question today: stackoverflow. Com/questions/6165425/… where calling First inside the query was source of the problem.
– Ladislav Mrnka May 29 at 13:40 @Ladislav Interesting. I guess they'll have to try it out to see what works. Redoing the design would of course remove the need for the FirstOrDefault.
– juharr May 29 at 13:45 I just made some test and FirstOrDefault will probably work because it behaves differently then First. – Ladislav Mrnka May 29 at 14:24.
You might want to redo your EF entities. Right now you are saying that each course has multiple lecturers and a lecturer is either a professor or an assistant. But your course index view seems to indicate that each course should have one professor and multiple assistants.
You also are indicating that a lecturer can only be a professor or an assistant. I would first make sure that a professor of one course cannot be the assistant of another first. If that is the case then I would create a separate table (or entity) for professors and assistants.
Make each course have one professor and multiple assistants. On the other hand if professors can be assistants then you need to remove the professor designation from the lecturer and build it into the relationship to the courses by having each course have one lecturer that is the professor and a list of lecturers that are the assistants.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.