在“SelectMany”的调用中,类型推断失败 [英] Type inference failed in the call to 'SelectMany'
本文介绍了在“SelectMany”的调用中,类型推断失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个LINQ查询:
I have this LINQ query:
var businessAffiliates = from b in context.Businesses
from ba in b.BusinessOfficers
from p in ba.Person
select b;
但我收到此错误:
类型
'myproj.Models.Person'的表达式不允许在查询中的后续from子句
表达式,源类型为
'System.Linq.IQueryable'。
调用
'SelectMany'时,类型推断失败。
An expression of type 'myproj.Models.Person' is not allowed in a subsequent from clause in a query expression with source type 'System.Linq.IQueryable'. Type inference failed in the call to 'SelectMany'.
推荐答案
p>它看起来像ba.Person它是单个对象,但来自子句的期望一系列对象。
子句中添加额外的
如果您用 let p = ba.Person
替换该行,那么它将工作。但是我想知道为什么您需要从。
It looks like ba.Person it a single object, but the from
clause expects a sequence of objects.
if you replace that line with let p = ba.Person
then it would work. But i wonder why you need those additional from
clauses.
这篇关于在“SelectMany”的调用中,类型推断失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文