Tuesday, October 25, 2011

.Contains Pitfall! Beware!

var foo = GetAll().Where(f => bar.Contains(f.Id));

 
 

...is going to crash if bar has no items. It's not enough for the collection to be not null. A collection with zero records causes an error.

No comments:

Post a Comment