从NOT IN到SQL到LINQ的转换 [英] SQL to LINQ conversion with NOT IN

查看:80
本文介绍了从NOT IN到SQL到LINQ的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请为mysql查询形成LINQ查询

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;

请帮帮我 谢谢

推荐答案

完全没有经过测试,但是这些行中的某些内容应该可以工作...

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

这篇关于从NOT IN到SQL到LINQ的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆