locked
Join 2 entities RRS feed

  • Question

  • User1979860870 posted

    Hi

      I have 2 entities . How to join the 2 .

    I want to display EmployeeId,EmployeeName,DepartmentName. Secondly i want to do below query using USING 

    Employeeid,EmployeeName,DepartmentId

    DepartmentId,DepartmentName

    var results = (from d in db.Employees
                               join f in db.Departments
                               on d.DepartmentId equals f.ID
                               select new
                               {
                                   Id = d.ID,
                                   Name = d.Name,
                                   Department = f.Description
                               }).ToList();
    
                return Ok(results);

    Thanks

    Thursday, February 18, 2021 4:32 AM

Answers

  • User1979860870 posted

    Resolved

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2021 6:04 AM