Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# query for "doesn't contain"

Tags:

f#

There's a query to search for when an item is contained in a list, but there isn't one for when an item isn't.

This query finds customer objects which don't have ContactNum in the given list cdiffnums. What could I do to return just the customers that dont have a ContactNum in this list?

let q =
    query {
        for c in dc.Customers do
        where (query { for n in cdiffnums do contains c.ContactNum })
        select c
    }
like image 921
Rei Miyasaka Avatar asked Mar 26 '26 20:03

Rei Miyasaka


1 Answers

My F# is rusty, but have you tried:

let q =
    query {
        for c in dc.Customers do
        where (not (query { for n in cdiffnums do contains c.ContactNum }))
        select c
    }
like image 197
NPSF3000 Avatar answered Mar 29 '26 11:03

NPSF3000