Sunday 23 October 2011

SingleOrDefault is throwing exception with message "Sequence contains more than one element"

When executing following linq with SingleOrDefault option I get following message
"Sequence contains more than one element"
Reason: only succeed when the collections contains exactly 0 or 1 element


Resolution: use FirstOrDefault as it will return first instance


http://stackoverflow.com/questions/1256757/sequence-contains-more-than-one-element

No comments:

Post a Comment