Hi,@coder rock. Welcome to Microsoft Q&A.
You could refer to the following code to achieve the function you want.
int personId = 12345;
var query = from fnte in t1
where fnte.status == "Notify" && fnte.fitterId == personId
join nte in t2 on fnte.fitterNotesId equals nte.fitternotesid
join p in t3 on nte.personId equals p.personId
join prs in t4 on fnte.createdBy equals prs.personId into prs_join
from prs in prs_join.DefaultIfEmpty()
join fo in t5 on new { prop1 = fnte.fitterId,prop2 = p.organizationId } equals new { prop1 = fo.personId, prop2 = fo.organizationId }
where fo.isActive == 1
select new
{
p.fName,
p.lName,
p.personId,
p.assignedId,
doId = 0,
notesId = nte.notesId ?? 0,
fitterNotesId = fnte.fitterNotesId ?? 0,
requestId = nte.requestId ?? 0,
notes = nte.notes ?? "",
CreatedByFirstName = prs.firstName ?? "",
CreatedByLastName = prs.lastName ?? "",
fnte.fitterId,
createdDate = fnte.dateCreated.HasValue ? fnte.dateCreated.Value.ToString("MM/dd/yyyy") : "01/01/1900",
createdBy = fnte.createdBy ?? 0,
modifiedBy = fnte.modifiedBy ?? 0
};
var result = query.Distinct().ToList();
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.