Skip to content
Loading
  • Jignesh Kumar
    +1
    Hi Adalat,
     
    Your code looks good,
     
    Your employeeCode and emaployee id coulmn both same ?
     
    If both same then please verify which values is going in Id column while calling this action method SearchEmployeePassportInfoByID.
     
    Which id is going by calling method should be exists in both the tables. 
    +1
  • Faisal Pathan
    +1
    or try this  where p.EmpCode == id
    +1
  • Jignesh Kumar
    +1
    Your query is correct only please check which id is going from your paremeter. For time being hard code id like below and check its returning result or not
     
    1. public IActionResult SearchEmployeePassportInfoByID(string id)  
    2. {  
    3. var empPassportInfo = from p in dbContext.PassportDetails  
    4.                                       join emp in dbContext.EmployeeGeneralDetails on p.EmpCode                                            equals emp.EmpCode  
    5.                                       where emp.EmpCode == "1012"
    6. select new RetrieveEmployeePassportDetails  
    7. {  
    8. EmpCode = p.EmpCode,  
    9. EmpFullName = emp.EmpFullName,  
    10. IssuingCountry = p.IssuingCountry,  
    11. IssueDate = p.IssueDate,  
    12. ExpiryDate = p.ExpiryDate  
    13. };  
    14.    
    15. return PartialView(empPassportInfo);  
    16. }
    +1
  • Faisal Pathan
    0
    As you write without where condition its working, so you should check EmpCode is avialable or not which you are passing as id.
    0
  • Madan Shekar
    0
    query wise no problem please check with your data only..
    0
  • Adalat  Khan
    0
    The EmpCode is available in both the tables
    0
  • Jignesh Kumar
    0
    Hi Adalat,
     
    Which Id you are passing that id available as Empcode in both table.
    If yes then only it will fetch record bcz we are joining two tables. 
    0
  • Faisal Pathan
    0
    first execute sql query with same empcode and check data is available or not
    0
  • Adalat  Khan
    0
    Following is the Record of PassportDetails Table:
     
    PassportNumber      EmpCode            IssuingCountry           IssueDate         ExpiryDate
    LN1798952               1154                      India                         2014-03-07       2019-03-06
    M0402440                 1108                      India                         2014-08-26       2024-08-08
    M3070951                 1205                      India                         2014-10-24       2024-10-23
    M4175873                 1188                      India                         2014-10-28        2024-12-04
    M4763544                 1147                      India                         2015-01-21        2025-01-20
    M5255530                 1166                      India                         2014-11-18         2018-03-01
    N1717614                 1152                      India                         2015-08-07         2025-08-06
    P00286015               1012                      India                         2013-05-25         2018-05-24
     
    Following is the Record of EmployeeGeneralDetails Table:
     
    EmpCode                        EmpFullName
    1012                                AMRAN HUSSAIN AWALEH
    1108                                KRISHNAN RAMESH
    1147                               MUHAMADU KANNU
    1152                               AMRUTHA SHEEJA
    1154                               SHAHID ALI
    1166                               MUHAMMAD SHAFEEL
    1188                              PRIYANKA
    1205                              ALEX JOHN
     
    I want to display all the fields from PassportDetails table and only one field that is EmpFullName from the EmployeeGeneralDetails table. Please join these two tables and display record by EmpCode. 
    0