asp.net core mvc - Difference between ToList()[0] and FirstOrDefault() -
i'm debugging mvc6 (beta7) application. found if execute test code, collection has elements (as should).
reservations.tolist()[0].requestedvehicletype.photos // photos.count == 1
with same data, original code resulted in empty collection.
reservations.firstordefault().requestedvehicletype.photos // photos.count == 0
what's more strange if call reservations.tolist() before 2nd code executed, result good.
reservations.tolist(); reservations.firstordefault().requestedvehicletype.photos // photos.count == 1
i understand mvc6 in beta, , may have bugs. question if 1 expected behavior or bug?
all navigation property scenarios not implemented in beta 7, wait beta 8 and/or try daily builds
Comments
Post a Comment