c# - How do I filter db.table by another another column from another table in MVC 5? -


i trying list of new potential borrowers not existing borrowers. have 2 tables in mvc application mapped using ef 5. both tables have field named client_name;

var existingborrower = s in db.existingborrower select s.client_name; 

i can confirm existingborrower.tolist() returns list of items existing borrowers.

i can't code below work. trying exclude list of existingborrowers not 1 item.

var newborrowers = db.allclients.where(x => !x.client_name.contains(existingclients.asenumerable())); 

supposing both tables have key of client called 'id' unique , has same value 1 client in 2 tables, or may primary key in 1 table , foreign key in second table:

var existingids = db.existingborrower.select(x => x.id).tolist();  var newborrowers = db.allclients.where(x => !existingids.contains(x.id)); 

this query translate in sql condition

where id not in (val1, val2 ,val3, ...) 

Comments

Popular posts from this blog

multithreading - Exception in Application constructor -

React Native allow user to reorder elements in a scrollview list -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -