SQL to LINQ conversion with NOT IN

匆匆过客 提交于 2019-12-23 05:17:29

问题


please form a LINQ query for the mysql query

select a.name ,a.amount 
from acount as a 
where a.acountid NOT IN (select c.id from saving as c where c.userid="x") 
and a.userid="x";
X=1;

Please help me out Thanks


回答1:


Have not tested at all but something in these lines should work...

var query =    
    from a in db.Account
    where !(from s in db.Savings 
            where s.UserId == "x"
            select s.id)    
           .Contains(a.AccountId)    
    && a.UserId == "x"
    select new { a.Name, a.Amount };


来源:https://stackoverflow.com/questions/11493861/sql-to-linq-conversion-with-not-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!