1

我不知道为什么这不起作用(引发内部异常)。有人可以帮忙吗?

    var flightCrew = from crew in crews
        medium inner join flight in flights on crew.Model equals flight.Model
        into schedule from flight in schedule.active()
4

1 回答 1

1

我不知道到底什么是中等内部连接。我想你的意思是左加入?尝试这个:

 var flightCrew = from crew in crews
                  join flight in flights on crew.Model equals flight.Model
                   into schedule from flight in schedule.DefaultIfEmpty()
                  select new
                         {
                            //the following are sample fields
                            crew.CrewId,
                            crew.Name,
                            FlightName = flight != null ? flight.Name : ""
                         }

请注意,无论您从中获取什么字段flight,都必须对其执行空值检查。

于 2012-05-24T16:41:33.530 回答