答案 0 :(得分:2)
from room in context.Rooms
let firstGuest = room.Guests
.OrderBy(x => x.CheckInDate)
.FirstOrDefault()
select new
{
RoomName = room.Name,
GuestName = firstGuest.GuestName,
CheckInDate = firstGuest.CheckInDate
};
实体框架不支持PARTITION BY
,而是最有可能使用CROSS APPLY
生成查询。