Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
798 views
in Technique[技术] by (71.8m points)

linq - Type inference failed in the call to 'SelectMany'

I have this LINQ query:

        var businessAffiliates = from b in context.Businesses
                                 from ba in b.BusinessOfficers
                                 from p in ba.Person                                     
                                 select b;

but I am getting this error:

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'.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...