Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5975105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:02:10+00:00 2026-05-22T21:02:10+00:00

I’m stuck trying to find a solution to this problem. Its a question taken

  • 0

I’m stuck trying to find a solution to this problem. Its a question taken from an exam for an interview. I will mark this as homework as my last question was tagged for me that way.

I have this object model:

Department: DepartmentId, Name

Teacher: TeacherId, FirstName, LastName, DateOfBirth, AnnualSalary, DepartmentId

Course: CourseId, Name, TeacherId, DepartmentId

Student: StudentId, FirstName, LastName, DateOfBirth, AverageScore, DepartmentId

Department has a 1 to many relationship with Teacher, Student and Course.

Teacher has a 1 to many relationship with Course
*Student* has a many to many relationship with Course

In a previous question I asked on here I asked how to create an interface between Student and Teacher called IPeople to highlight all commonality. I was pointed in the right direction and came up with

            using System;
            using System.Collections.Generic;
            using System.Linq;
            using System.Text;

            namespace School.Code
            {
                public interface IPeople
                {
                    string FirstName
                    {
                        get;
                        set;
                    }
                    string LastName
                    {
                        get;
                        set;
                    }
                    Int64 DepartmentId
                    {
                        get;
                        set;
                    }
                    DateTime DateOfBirth
                    {
                        get;
                    }

                }
            }

I then needed to create an IENumerable value of IPeople which I did using

           public IEnumerable<IPeople> GetAllIPeople()
            {
                foreach (IPeople person in GetAllTeachers())
                {
                    yield return person;
                }
                foreach (IPeople person in GetAllStudents())
                {
                    yield return person;
                }
            }

How ever I am stuck with the next part of this.

The question is. Write method to get all IPeople for a Course – Write a method in the SchoolManager to get all IPeople for a particular Course. Your method should return an IENumerable of IPeople and make use of the existing GetAllIPeople method you’ve just written in the SchoolManager.

Now at first I thought this would be easy and should just use .where(c => c.CourseId == cId) where cId was passed into the method. How ever CourseId isnt in the interface as its not a common property between Student and Teacher. I do know because of the relationships between the objects that the Course, Student and Teacher will all share the same DepartmentID.

I am however completely lost as to how I produce an answer to this question. If anyone can point me in the right direction I would be grateful.

Using Microsoft Visual Studio 2010 with MS Entity Framework 4.0

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:02:11+00:00Added an answer on May 22, 2026 at 9:02 pm

    If you think of it in terms of a Course owning people rather than trying to discover courses from people, you won’t face this problem. So in meta-code:

    Course course=....
    foreach(IPeople person in course.Students) //or whatever
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.