0

这很好,它产生一个左连接

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 };

但是如果我想做这样的事情怎么办:

...
on p.date between c.startdate and c.enddate
...
4

1 回答 1

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 };
于 2010-03-15T14:33:51.940 回答