I was trying to be clever the other day and try to chain assertions on an array: [ Test ] public void This_does_not_work() { var items = new [] {1, 2, 3, 4, 5}; items .Each(x => x.ShouldBeLessThan(0)) .Each(x => x.ShouldBeGreaterThan(10)); } I did this by writing an Each extension method that I've...
I ran across a couple of scenarios the other day that were made pretty difficult given the current LINQ query operators. First, I needed to see if an item existed in a collection. That's easy with the Contains method, when you want to find item that matches all the attributes you're looking for...
Now that .NET 3.5 is out with all its LINQ query operator goodness, I feel like going on a mean streak of trashing a lot of our (now) pointless foreach loops. Some example operations include: Transformations Aggregations Concatenations Filtering As I mentioned in my last post , temporary list creation...
The "big 3" higher-order functions in functional programming are Filter, Map and Reduce. When looking at the new C# 3.0 LINQ query operators, we find that all three have equivalents : Filter = Where Map = Select Reduce = Aggregate Whenever you find yourself needing one of these three higher...