LINQ to SQL: making a "double IN" query crashes
Posted
by Alex
on Stack Overflow
See other posts from Stack Overflow
or by Alex
Published on 2010-04-01T01:04:19Z
Indexed on
2010/04/01
1:13 UTC
Read the original article
Hit count: 292
asp.net-mvc
|linq-to-sql
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.
© Stack Overflow or respective owner