我在 EF 中有Room和Bed类,每个类Room都有一些Bed(s)。我有一个从 EF 检索到Collection的s ;我使用此代码访问s( )中的所有s :RoomcontextBedCollectionRoommyRooms
IEnumerable<Room> myRooms=...
IEnumerable<Bed> bedsInMyRoom=context.Beds.AsEnumerable();
foreach (IEnumerable<Bed> beds in myRooms.Beds)
{
if(beds!=null && beds.Any())
bedsInMyRoom=bedsInMyRoom.Concat(beds);
}
在性能上有没有更好的方法来做到这一点?