这是我的 SQL 命令
SELECT KEY,NAME
from COMPANY c
WHERE KEY IN (select KEY from USER_COMPANY where UserId = @UserId)
order by NAME asc
所以我想将它转换为实体框架。
我试试这样
var userCompany = (from u in db.USER_COMPANY
where u.UserId == UserId
select(u.KEY));
var user = (from c in db.COMPANY
where (c => userCompany.Contains(c.KEY)
select c);
但它不工作。
如何IN
在实体框架中使用 SQL 关键字?