int id =2 ;
(from t1 in Table1
join t2 in Table2
on new { t1.id, id} equals new { t2.id, t2.otherid }
select t1).ToList();
Currently the above query gives me a compilation error saying
The type on one of the join expressions is incorrect.
As you can see in the above query I want to join on a single integer value as you would in sql. I want to these so that query is faster and I don’t want to do a where at the end because that would mean it will get all the rows and then filter with the where clause. As I have lot of rows in both the tables it would be good if I can filter rows on join clause itself. Thanks for your help !
You need to use the same anonymous type (with the same property names) in both halves of the join:
Your text implies that you actually want to join on a single value; if so, you don’t need an anonymous type at all: