mangonugen / morelinq

Automatically exported from code.google.com/p/morelinq
Apache License 2.0
1 stars 0 forks source link

TryWhere() TrySelectOrFallback() #74

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
TryWhere(predicate)

TryWhere should behave as regular Where, but also filter out the items where 
the predicate throws exception.

Many times a Where clause may be accessing a dictionary, or it may have have a 
long invocation chain within the item where null checks are impractical and 
only the "happy case" should have to be considered.

Of course it is undesirable to create a lot of exception, but the benefit in 
code clarity can often be worth it. This may also be the difference from using 
a lambda expression to using a named predicates declared elsewhere. Inlined 
predicates become less readable with a sprinkled "if null" , "if 
.ContainsKey()" and "if .Any()".

Original issue reported on code.google.com by tormod.s...@gmail.com on 16 Jun 2012 at 12:23