3

当一个项目包含在列表中时,有一个查询可以搜索,但当一个项目不包含时,没有一个查询。

此查询查找给定列表中customer没有的对象。我能做些什么来只返回此列表中没有的客户?ContactNumcdiffnumsContactNum

let q =
    query {
        for c in dc.Customers do
        where (query { for n in cdiffnums do contains c.ContactNum })
        select c
    }
4

2 回答 2

3

我的 F# 生锈了,但你试过吗:

let q =
    query {
        for c in dc.Customers do
        where (not (query { for n in cdiffnums do contains c.ContactNum }))
        select c
    }
于 2012-08-19T00:47:13.643 回答
1

我认为这样的事情应该有效:

open System.Linq

let cdiffnums = [|1;2;3|]
let q =
    query {
        for c in dc.Customers do
        where (not (cdiffnums.Contains c.ContactNum))
        select c
    }
于 2012-08-19T03:06:06.563 回答