Laziale
Laziale

Reputation: 8225

LINQ error, 'the type of one of the expressions in the join clause is incorrect", when trying to use two joins

I have this LINQ expression where I'm trying to add a second join, but I'm getting an error.

This is the query I have:

            from x in db.Sales
            join y in db.Sales on x.ID equals y.ID - 1
            join z in db.Locations on x.Line equals z.LocationCode
            where Convert.ToInt32(y.Order) >= Convert.ToInt32(x.Order)
            orderby x.OrderDate ascending
            select x).Distinct()

And this is the error I'm getting:

The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'.

Is there anything I need to change in that second join to not get that error?

Upvotes: 1

Views: 4502

Answers (1)

D Stanley
D Stanley

Reputation: 152521

Apparently x.Line and z.LocationCode are incompatible types. You could change one or the other to an expression that would make both sides compatible.

Upvotes: 4

Related Questions