1

试过这个:

myStructs = from MyObject s in MyObjects
            join c in Categories on s.CategoryID equals c.Item1 && s.Stars equals c.Item2
            select s;

但似乎我不能在加入时写 2 个条件?我哪里错了?在 SQL 上,这也可以完成......

4

1 回答 1

2

您需要一个匿名类型来加入多个条件/字段:

myStructs = from s in MyObjects
            join c in Categories 
            on new { s.CategoryID, s.Stars }  equals new { CategoryID = c.Item1, Stars = c.Item2 }
            select s;
于 2012-07-17T15:36:20.253 回答