0

This is fine, it produces a left join

var q =
    from c in categories
    join p in products 
    on c equals p.Category into ps
    from p in ps.DefaultIfEmpty()
    select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName };

But what about if I wanted to do something like this:

...
on p.date between c.startdate and c.enddate
...
Patrick Karcher
  • 22,995
  • 5
  • 52
  • 66
Martin
  • 2,956
  • 7
  • 30
  • 59

1 Answers1

1
var q =
    from c in categories
    join p in products 
    on c equals p.Category into ps
    from p in ps.DefaultIfEmpty()
    where p.date >= c.startdate && p.date <= c.enddate
    select new { Category = c, ProductName = p == null ? "(No products)" : p.ProductName };
  • Except I'm not interested in the original on clause. I replaced it with on 1 equals 1. Won't that be terribly burdensome though? – Martin Mar 15 '10 at 14:56