Hi @Anjali Agarwal
I have JobTitleLookupId in my employeeeInfo database table. How can i get the name of the jobtitle if i have the corresponding ID in employeeInfo Table. how can I get Title using LINQ if I query the employeeInfo table.
You can get the job title according to the Navigation property: JobTitleLookup.
The LINQ query statement as below: use Inculde method to load the related entity. More detail information, see Eager Loading of Related Data.
var id = 2;
var query = _dbcontext.EmployeeInfos
.Include(c => c.JobTitleLookup)
.Where(c => c.EmployeeInfoId == id)
.Select(c => new
{
EmployeeInformId = c.EmployeeInfoId,
FirstName = c.FirstName,
Title = c.JobTitleLookup==null?"null":c.JobTitleLookup.Title
}).ToList();
The result as below:
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Dillion