How can I achieve Outer Apply in LINQ? I\'m having a bit of a problem.
Here\'s the SQL Query I\'m using.
SELECT u.masterID
,u.user
,h.created
Outer Apply produces results of left outer join,
the query should be:
var q =
from u in db.Users
join h in db.UserHistory on u.masterID equals h.masterID into ps
from p in ps.DefaultIfEmpty()
select new {
masterID = u.masterID
,user = u.user
,created = ps.OrderByDescending(x=>x.created).FirstOrDefault()==null?null:ps.OrderByDescending(x=>x.created).First().created
};