日期:2014-05-20  浏览次数:20808 次

急切求助,在线等,马上结,这条SQL用linq怎么写


  select A.a,B.b from A left join B on A.a=B.a and A.date Between xxxxx and xxxxx

  。。我刚开始学。。。
 

------解决方案--------------------
不好意思,漏写查询项啦:
from c in A join d in B on c.a equels d.a where A.date.compareTo(date1) > 0 && A.date.compareTo(date2) < 0 select new {A.a,B.b};
或:
from c in A join d in B on c.a equels d.a where A.date.compareTo(date1) > 0 && A.date.compareTo(date2) < 0 select new {XXX = A.a, YYY = B.b};
------解决方案--------------------
var q = 
from e in db.Employees 
join o in db.Books on e.EmployeeID equals o.EmployeeID into b
where e.date.compareTo(date1) >= 0 && e.date.compareTo(date2) <= 0
from x in b.DefaultIfEmpty() 
select new 

e.ID, 
e.Name, 
o.BookName 
};