Hello,
I need some assistance with a LINQ query. I've got a simple query:
var q = from t in db.Table1 select t;
Based on user input I'm adding some where clauses:
if (condition1)
q = q.Where(t =t.Field1==1);
if (condition2)
q = q.Where(t =t.Field2==2);
Table1 has a sub table. Based on a condition I want find the Table1 records
that have one or more Table2 records. If I were using sql I would do
something like this:
select * from Table1 t1 where exists (select * from Table2 t2 where
t1.id=t2.id and t2.field1='somevalue')
How can I do this in LINQ given that I have added the above where clauses
based on those conditions?
Thanks,
Nick