Linq查询不在运算符中 [英] Linq query not in operator

查看:85
本文介绍了Linq查询不在运算符中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我需要在操作符中不使用.

我有一种返回客户数组的服务方法
而且我还有一个表,可以返回客户列表
两者中都有一个相同的参考字段字符串
我只需要从服务中获取那些客户
其参考号不在本地数据库中的
我正在执行以下操作,但它不起作用,我正在将实体框架用于本地
数据库.

Hi guys

I need to use not in operator.

I have a service method which returns array of customers
and also i have a table which return list of customers
there is a reference field string same in both
i need to fetch from service only those customer
whose reference number is not in the local data base,
i am doing following not it does not work , i am using entity framework for local
data base.

var qry = from e in _client.GetCustomers(APIKey)
          where entities.Customers.Any(a=> e.Reference== a.Reference)
          select e;





regards.

推荐答案

看看这篇文章

http://introducinglinq. com/blogs/marcorusso/archive/2008/01/14/the-not-in-clause-in-linq-to-sql.aspx [
Have a look at this article

http://introducinglinq.com/blogs/marcorusso/archive/2008/01/14/the-not-in-clause-in-linq-to-sql.aspx[^]

e.g

var query =
    from e in _client.GetCustomers(APIKey)
    where !(from o in _client.GetCustomers(APIKey)
            select o.Reference)
           .Contains(e.Reference)
    select e;


这篇关于Linq查询不在运算符中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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