Adalat  Khan

Adalat Khan

  • 624
  • 1.5k
  • 846k

LINQ Query Where Clause when join two tables

Mar 11 2019 12:07 AM
When i join two tables using LINQ then it working properly but when i join two tables and i use the Where Clause then the LINQ query does not display any record. Following is my complete Action Method in which i joined two tables one is EmployeeGeneralDetails table and another one is PassportDetails table. Its working without the Where Clause but when i want to display a single record using the Employee ID and i used the Where condition then its not working. Please check my Where clause why its not working. Following is the Action Method:
 
 
public IActionResult SearchEmployeePassportInfoByID(string id)
{
var empPassportInfo = from p in dbContext.PassportDetails
                                      join emp in dbContext.EmployeeGeneralDetails on p.EmpCode                                            equals emp.EmpCode
                                      where emp.EmpCode == id 
select new RetrieveEmployeePassportDetails
{
EmpCode = p.EmpCode,
EmpFullName = emp.EmpFullName,
IssuingCountry = p.IssuingCountry,
IssueDate = p.IssueDate,
ExpiryDate = p.ExpiryDate
};
 
return PartialView(empPassportInfo);
}
 

Answers (10)