Well this isn't exactly clever but I've modified the ----OrDefault methods so you could specify a default item inline instead of checking for null later in your code:
public static T SingleOrDefault ( this IEnumerable source,
Func action, T theDefault )
{
T item = source.SingleOrDefault(action);
if (item != null)
return item;
return theDefault;
}
Its incredible simple but really helps clean up those null checks. Best used when your UI is expecting a list of X items, like a tournament system, or game player slots and you want to display "empty seats".
Usage:
return jediList.SingleOrDefault(
j => j.LightsaberColor == "Orange",
new Jedi() { LightsaberColor = "Orange", Name = "DarthNobody");