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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -