Adalat  Khan

Adalat Khan

  • 652
  • 1.5k
  • 865.1k

Joining of two tables on Multiple fields

Sep 20 2021 3:10 PM

Hi, I have the following Linq query in which i am joining two tables using multiple fields but it gives me error that "The Type of the expression in Join Claus is incorrect. Type inferences fails in the call to group join":

 var depAirportCode = from b in dbContext.Bookingsjoin f in dbContext.Flights on new{Key1 = b.FlightInfoId,Key2 = b.OperatingAirlineCode,Key3 = b.RequestedFlightNumber}equals new{Key1 = f.FlightInfoId,Key2 = f.OperatingAirlineCode,Key3 = $"{f.OperatingAirlineCode}{f.OperatingFlightNumber}"}into result where b.BookingReference == "AP15-1464"
select b.DepartureAirportCode;

Answers (2)