Guest User

Untitled

a guest
Jan 19th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. on Bar.Id equals Foo.BarId1 or Bar.Id equals Foo.BarId2
  2.  
  3. var data = (from f in Foos
  4. join b in Bars on f.BarId1 equals b.Id into tb
  5. from xb in tb.DefaultIfEmpty()
  6. join b in Bars on f.BarId2 equals b.Id into tb2
  7. from xb2 in tb2.DefaultIfEmpty()
  8. select new { Foo = f, Bar1 = xb, Bar2 = xb2 });
  9.  
  10. var data = from f in Foos
  11. from b in Bars.Where(x => x.Id == p.BarId1 || x.Id == p.BarId2).DefaultIfEmpty()
  12. select new { Foo = p, Bars = b };
  13.  
  14. Foo Bar
  15. f1 b1
  16. b2
  17.  
  18. Foo Bar
  19. f1 b1
  20. f1 b2
  21.  
  22. var data = from f in Foos
  23. select new
  24. {
  25. Foo = f,
  26. Bar1 = Bars.FirstOrDefault(x => x.Id == f.Bar1Id),
  27. Bar2 = Bars.FirstOrDefault(x => x.Id == f.Bar2Id)
  28. };
  29.  
  30. var data = (from f in Foos
  31. join b in Bars on f.BarId1 equals b.Id into tb
  32. from xb in tb.DefaultIfEmpty()
  33. join b in Bars on f.BarId2 equals b.Id into tb2
  34. from xb2 in tb2.DefaultIfEmpty()
  35. select new { Foo = f, Bar1 = xb, Bar2 = xb2 });
  36.  
  37. from f in Foos
  38. select new { f, f.Bar1, f.Bar2 }
  39.  
  40. var data = from f in Foos
  41. from b in Bars
  42. where f.Id == b.BarId1 || f.Id == b.BarId2
  43. select new { Foo = p, Bars = bx };
Add Comment
Please, Sign In to add comment