我遇到了一個錯誤,「無法序列化接口System.Linq.IQueryable」。當我嘗試在我的Web服務中運行我的方法時。我的類是這樣:無法序列化接口System.Linq.IQueryable
public class AirlineSearchStrong
{
public Flight_Schedule flightSchedule { get; set; }
public Flight_Schedule_Seats_and_Price flightScheduleAndPrices { get; set; }
public Airline airline { get; set; }
public Travel_Class_Capacity travelClassCapacity { get; set; }
}
[WebMethod]
public IQueryable SearchFlight(string dep_Date, string dep_Airport, string arr_Airport, int no_Of_Seats)
{
AirlineLinqDataContext db = new AirlineLinqDataContext();
var query = (from fs in db.Flight_Schedules
join fssp in db.Flight_Schedule_Seats_and_Prices on fs.flight_number equals fssp.flight_number
join al in db.Airlines on fs.airline_code equals al.airline_code
join altc in db.Travel_Class_Capacities on al.aircraft_type_code equals altc.aircraft_type_code
where fs.departure_date == Convert.ToDateTime(dep_Date)
where fs.origin_airport_code == dep_Airport
where fs.destination_airport_code == arr_Airport
where altc.seat_capacity - fssp.seats_taken >= no_Of_Seats
select new AirlineSearchStrong {
flightSchedule = fs,
flightScheduleAndPrices = fssp,
airline = al,
travelClassCapacity = altc
});
return query;
}
我試過的IQueryable,IList的和返回.ToList(),但大部分已經被證明是不成功的
我得到無法序列接口System.Collections.Generic.IEnumerable'1 [Travel_Reservation_System.Services.AirlineSearchService + AirlineSearchStrong,旅行預訂系統,版本= 1.0.0.0 ,Culture = neutral,PublicKeyToken = null]]。作爲錯誤消息 –