I have 2 data sets with me as follow :
{
"email": "xyz@yopmail.com",
"courseId": "111",
"courseName": "Using Microsoft Azure Database Services",
"progress": 39,
"minutesWatched": 5.166667,
"lastActivity": "2022-01-06T00:00:00Z"
}
and
{
"email": "xyz@yopmail.com",
"courseId": "111",
"courseName": "Using Microsoft Azure Database Services",
"startDate": "2022-07-31T00:00:00Z",
"completeDate": null,
"completed": false
}
I want to left join the two lists on the basis of emailId and courseId. From the first list I want to extart all the info and from the second I want to get the values for completeDate
completed
and startedDate
. This is what I am using
var result = (from x in courseProgress
from y in courseCompletion
.Where(y => y.email.Equals(x.email, StringComparison.InvariantCultureIgnoreCase) && y.courseId.Equals(x.courseId, StringComparison.InvariantCultureIgnoreCase))
select new XYZ
{
email = x.email,
courseId = x.courseId,
courseName = x.courseName,
progress = x.progress,
minutesWatched = x.minutesWatched,
startDate = y.startDate,
completeDate = y.completeDate.HasValue ? y.completeDate : DateTime.MinValue,
completed = y.completed,
lastActivity = x.lastActivity
}).ToList();
However, I want to apply a left join so that I can get records from first list even when there is no matching record from the second list.