【发布时间】:2010-11-02 17:59:15
【问题描述】:
我收到以下错误:
The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.
当使用下面的代码时
var ccrCodes = (from c in db.CCRCodes
join i in items on
new { c.baan_cat_fam_code, c.baan_cat_code } equals
new { i.baan_cat_family_code, i.baan_cat_code }
where i => i.contact_dt.Value.Year == date.Year && i.contact_dt.Value.Month == date.Month
select c).Distinct().OrderBy(c => c.code_desc);
我在 LINQ 中尝试做的是创建一个多条件连接并且遇到了问题。有什么想法吗?
谢谢,
【问题讨论】:
-
正如我在下面的评论中提到的,您可能对使用 SelectMany 方法在 LINQ to SQL 中执行连接感兴趣。它应该为您简化事情。见When to prefer joins expressed with SelectMany() over joins expressed with the join keyword in Linq。
标签: linq linq-to-sql join