views:

28

answers:

1

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
...
+1  A: 
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 };
Developer Art
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