score:6

Accepted answer

you are pretty close: all you need to do is selecting ids, and then using contains, like this:

var supplierproductids = db.supplierproducts
    .where(w => w.supplierid == supplierid)
    .select(p => p.productid)
    .tolist(); // you could get better performance without tolist
ienumerable<products> products = db.products
    .where(w => supplierproductids.contains(w.productid))
    .tolist();

score:0

if you have constructed you model correctly you should have the virtual property for products in supplier class

public virtual icollection<product> products {get; set;}

and this would have made your task easier:

 db.suppliers.where(s => s.id == supplierid).select(s => s.products)

Related Query

More Query from same tag