日期:2014-05-18  浏览次数:20845 次

如何把这sql变为Linq查询
SQL code

select *
from drugpar d
where d.kind in (select [id] from optiondic o where o.name="xiyao") 



------解决方案--------------------
var query = from x in drugpar
where optiondic.Where(y => y.name == "xiyao").Select(y => y.id).Contains(x.kind);
------解决方案--------------------
探讨
SQL code

select *
from drugpar d
where d.kind in (select [id] from optiondic o where o.name="xiyao")

------解决方案--------------------
Contains<drugpar>(c.kind)
应该是Contains<int>(c.kind)吧
------解决方案--------------------
用SQL多好为什么非要用LIQ。好像以后不支持LIQ TO SQL啦吧