LINQ to SQL: making a "double IN" query crashes
- by Alex
I need to do the following thing:
var a = from c in DB.Customers where (from t1 in DB.Table1 where t1.Date >= DataTime.Now select t1.ID).Contains(c.ID) && (from t2 in DB.Table2 where t2.Date >= DataTime.Now select t2.ID).Contains(c.ID) select a
It doesn't want to run. I get the following error:
Timeout expired. The timeout period
elapsed prior to completion of the
operation or the server is not
responding.
But when I try to run
var a = from c in DB.Customers where (from t1 in DB.Table1 where t1.Date >= DataTime.Now select t1.ID).Contains(c.ID) select a
OR
var a = from c in DB.Customers where (from t2 in DB.Table2 where t2.Date = DataTime.Now select t2.ID).Contains(c.ID) select a
It works!
I'm sure that there both IN queries contain some customers ids.