In SQL I can use the IN operator:
select * from project where id IN (select f.id_project from funds)
How can I convert this statement to LINQ?
Controller.Project.Where(p => p.id == id_funds); // I can assign only one id funds
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the
Containsmethod:Don’t think it applies to your question as it appears
id_fundslinks to a db table but…Note that if id_funds is an object (i.e. a simple array or list etc.), not something in the database and you’re not using Linq-To-Objects you may encounter issues with this as i don’t think Linq-To-Entities before v 4.0 supports it (see here for a workaround), and Linq-To-SQL has problems if
id_fundsis a very large list (more than around 2000 items).