LINQ - Contains with anonymous type
Posted
by Marlos
on Stack Overflow
See other posts from Stack Overflow
or by Marlos
Published on 2010-03-17T18:59:51Z
Indexed on
2010/03/17
19:01 UTC
Read the original article
Hit count: 305
When using this code (simplified for asking):
var rows1 = (from t1 in db.TABLE1
where (t1.COLUMN_A == 1)
select new { t1.COLUMN_B, t1.COLUMN_C });
var rows2 = (from t2 in db.TABLE2
where (rows1.Contains(t2.COLUMN_A))
select t2;
I got the following error:
The type arguments for method 'System.Linq.Enumerable.Contains(System.Collections.Generic.IEnumerable, TSource)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I need to filter the first result by COLUMN_B, but I don't know how. Is there a way to filter it?
© Stack Overflow or respective owner