I have two tables (TABLE1, TABLE2 - unique I know), which has a 1-to-many relationship and a foreign key between the ID columns of both tables.
Using linq2sql I am trying to select all the TABLE1 entries so that their corresponding TABLE2 values contain at least 1 element in the list that I go through it.
Here is an example of the code that I used in LINQPad (awesome program) to test it, but I get a NotSupportedException error : Unsupported overload used for the request operator "Any".
long[] items = { 3, 5, 8 };
var predicate = PredicateBuilder.False<TABLE2>();
foreach (long i in items)
{
long t = i;
predicate = predicate.Or(att => att.ID == t);
}
IQueryable query =
from t1 in TABLE1
where t1.TABLE2.AsQueryable().Any(predicate)
select a;
query.Dump();
UPDATE
LinqKit LinqPad LinqKit.dll, Include PredicateBuilder, LinqKit " ".