Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type inference failed in the call to 'SelectMany'

Tags:

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

like image 622
DotnetSparrow Avatar asked May 18 '11 18:05

DotnetSparrow


1 Answers

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.

like image 189
Botz3000 Avatar answered Sep 30 '22 09:09

Botz3000