Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not equal/not contains operation in lambda expressions

My query is some thing like:

var subQuery = contacts_requests.Where(i => i.requests_usr_id >= 1).Select          
           (i => i.Usr_contacts_requests_from_usr_id ).ToArray();
var query = biographic_details.Join(profiles_companies, i => i.usr_id, j => j.company_usr_id,
           (i,j)=>new{
                      Usr_bio_usr_id }).where(p=>subQuery.Contains(i.company_usr_id)).ToArray();

I want notcontains operation in place of contains, how can I implement that?

like image 349
steve Avatar asked Dec 08 '22 21:12

steve


1 Answers

Instead of

p => subQuery.Contains(i.company_usr_id) 

use

p => !subQuery.Contains(i.company_usr_id)

Note the ! before the method call. The ! operator (aka Logical negation operator) just negates the result of the following expression. So Contains becomes Not Contains.

like image 151
Botz3000 Avatar answered Jan 22 '23 23:01

Botz3000