Display names from IDs to employee tabels RRS feed

  • Question

  • User-833526072 posted

    Hi. Hopefully my last questions for a while.
    I have a project database, where i have 3 employees. 1 customer, 1 project manager and 1 project attendee.
    They all are from same database table Employees.

    Customer Company Customer Contact Project number Project Name Project manager Project Attendee
    google 1213 123456 My projects 1214 1215

    How can I print the names of ID "Customer Contact", "Project manager", "Project Attendee"?

    Here is my code to retrieve from database in 

    public ActionResult Index()
        Employee employee = db.Employees.Find(1007);
        var projects = db.Projects
            .Where(c => c.SupplierCompanyID == employee.CompanyID)
            .Include(p => p.Company)
            .Include(p => p.Employee)
            .Include(p => p.Projectmanager)
            .Include(p => p.ProjectType)
            .Include(p => p.Site);
        ViewBag.userID = employee.UserAccess;
        return View(projects);

    How can i do this?

    Wednesday, March 17, 2021 9:24 PM


  • User-833526072 posted


    I had to use in project class:


    and in Employee class i had to use [InverseProperty("ProjectAttendees")].

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 18, 2021 12:03 AM