Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LINQ - 'the type of one of the expressions in the join clause is incorrect'

Tags:

c#

linq-to-sql

I have a complex LINQ to SQL to query, which joins onto two tables - one is rather simple and works fine, but one is fairly complex and I'm getting The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin

It's a rather long query, and I do development on a work with Internet access so I thought I'd see if the line that seems to be the issue is enough:

join consignments in dc.Consignments
    .FirstOrDefault(x => x.TripDate > dateFrom 
    && x.TripDate < dateTo 
    && x.DeliveryDepot == depot.Letter 
    && (x.DeliveryStatus == 2 || x.DeliveryStatus == 3))
  on new { Reg = s.VehicleReg, Depot = s.VehicleDepot } 
      equals new { Reg = consignments.VehicleReg, Depot = consignments.DeliveryDepot }
  into con

I've ensured that the data types are the same, but it still doesn't work. Any ideas?

like image 997
Chris Avatar asked Apr 06 '11 14:04

Chris


1 Answers

Are you sure that s.VehiculeDepot is the same type as consignments.DeliveryDepot ?

on new { Reg = s.VehicleReg, Depot = s.VehicleDepot } 
equals new { Reg = consignments.VehicleReg, Depot = consignments.DeliveryDepot }
like image 199
mathieu Avatar answered Nov 15 '22 19:11

mathieu