join子句中表达式之一的类型在Entity Framework中不正确.左连接常数 [英] The type of one of the expressions in the join clause is incorrect in Entity Framework. Constant in left join
本文介绍了join子句中表达式之一的类型在Entity Framework中不正确.左连接常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在EF查询中进行左连接.我收到以下错误:
I'm trying to do a left join in an EF query. I'm getting the following error:
错误CS1941 join子句中的表达式之一的类型为 不正确.调用"GroupJoin"时类型推断失败
Error CS1941 The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'
这是C#代码:
var foo = from m in db.ClientMasters
join a in db.Orders on new { m.Id, Status = "N" } equals new { a.ClientID, a.Status } into a_join
from a in a_join.DefaultIfEmpty()
select new { m.ClientID, a.ID };
推荐答案
我是个白痴.联接中的列名必须匹配.这是更正的代码.
I'm an idiot. The column names have to match in the join. here is the corrected code.
var foo = from m in db.ClientMasters
join a in db.Orders on new { ClientID = m.Id, Status = "N" } equals new { a.ClientID, a.Status } into a_join
from a in a_join.DefaultIfEmpty()
select new { ClientID = m.Id, OrderId = a.Id };
这篇关于join子句中表达式之一的类型在Entity Framework中不正确.左连接常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文