-
Hello all, I was hoping someone could help me with writing the EF expression below. Im trying to perform two left outer joins to get the name of the user who created the notes and put the item on hold hold for the BookChange. It works when I only use one .GroupJoin expression but when I add the other one I get an error.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Here is copilot's suggestion:
} |
Beta Was this translation helpful? Give feedback.
-
I found the solution. I will post tomorrow. Dang it took me a while to find this. |
Beta Was this translation helpful? Give feedback.
-
Hello All, public Task GetAsync(string pchgDate, string pEngID) |
Beta Was this translation helpful? Give feedback.
Hello All,
Here is the solution to Lamda multiple outer join syntax. This has two joins to get who enter the notes and who put the record on hold.
public Task GetAsync(string pchgDate, string pEngID)
{
var data = _context.BookChanges
.GroupJoin(_context.LookUpUsers, p => p.NotesBy, n => n.UserName, (p, n) => new { p, n })
.SelectMany(p => p.n.DefaultIfEmpty(), (p, n) => new { p.p, n })
.GroupJoin(_context.LookUpUsers, pn => pn.p.HoldBy, h => h.UserName, (pn, h) => new { pn, h })
.SelectMany(pnh => pnh.h.DefaultIfEmpty(), (pnh, h) => new { pnh,h})
.Where(x => x.pnh.pn.p.PchgDate == pPchgDate && x.pnh.pn.p.EngID == pEngID)
.Select(s => new BookChangeEntity
{
BookChangeID = s.pnh.pn.p.BookCh…