debugging issue
Hello folks, I have a problem I hope I can explain what's happening.
When I have break points on certain blocks of code the desired select statement that selects SingleOrDefault works fine.
Without breakpoints (on normal debuging) the list has more than one item then an exception fires and says "sequence contains more than one element".
3 Replies
FirstOrDefault is the version you use if more than 1 item being in the list is acceptable
SingleOrDefault is used if you want there to always be 0 or 1 items
The thing I I have to use SingleOrDefault and it's working fine when there is breakpoint
Otherwise it doesn't
It might be that with the breakpoint only one item has been added to the list when SingleOrDefault is called and without the breakpoint more items get added to the list