I was trying to find a way to perform a left join on 2 comparable sets of data using LinQ, but the join keyword only appears to perform an inner join (unless I missed something).
By performing a LinQ statement for the Del entry at the point I create the anonymous type, the following output would act like a left join (returning a null for the Del value when there is no match).
I then go on to select all the null entries using the extension methods and call a delete routine for each entry found.
(from x in Entries
where x.Information["Information3"] == Session["GINumber"].ToString()
select new
{
Pre = x,
Del = (from y in _delegates
where y.EmailAddress == x.Information["Information1"]
select y.EmailAddress).SingleOrDefault()
}).Where(x => x.Del == null).ToList().ForEach(x => Service.DeleteEntry(x.Pre.InformationID));
As an aside I found out that the term for the “from” “in” style of LinQ is called “Query Comprehension Syntax”.
No comments:
Post a Comment