该类型前pressions之一的诠释,他的加盟条款不正确。类型推断在调用'加盟'失败 [英] The type of one of the expressions int he join clause is incorrect. Type inference failed in the call to 'join'
本文介绍了该类型前pressions之一的诠释,他的加盟条款不正确。类型推断在调用'加盟'失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前,我正在试图加入另一个表中的列到现有的表,并将其返回到MVC 4
I'm currently trying to join a column from another table to an existing table and return it to the view in MVC 4
var q = from accCo in db.AccControls
join accCom in db.AccCompanies
on new { accCo.ControlCode } equals
new { ControlCode = accCom.Code }
where accCo.ControlCode == Request.QueryString["ControlCode"]
orderby accCom.Code
select new Combined{ AccControls = accCo, AccCompoanies = accCom };
return View(q);
但我发现了上面的错误
But I'm getting the above error
推荐答案
如果你任何关于加盟列可为空,则需要将其更改为.value的
If any of the columns you join on is nullable, you will need to change it to .Value
on new { accCo.ControlCode } equals
new { ControlCode = accCom.Code.Value }
或者您可以使用此
or you can use this
var q = from accCo in db.AccControls
join accCom in db.AccCompanies
where accCom.Code != null
on new { accCo.ControlCode } equals
new { ControlCode = accCom.Code }
where accCo.ControlCode == Request.QueryString["ControlCode"]
orderby accCom.Code
select new Combined{ AccControls = accCo, AccCompoanies = accCom };
这篇关于该类型前pressions之一的诠释,他的加盟条款不正确。类型推断在调用'加盟'失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文