Linq

C# Case Expression via Extension Methods

5 minute read Published:

As a veteran C# developer yourself, I’m sure you’re familiar with the switch statement. Since it is a statement this means you cannot effectively use this ever-so-useful construct in an expression, such as in a LINQ query. This is a shame, and it irks me greatly that I have to resort to emulating the switch behavior with a series of chained ternary operators (a ? b : c ? d : e ?

LinqFilter: Run LINQ Code From The Command Line Interface!

4 minute read Published:

Having recently acquired a taste for using git on Windows with msysGit, I’ve been getting a lot more productive with my use of bash and other command-line tools in Windows. Shifting data around on the command line gets pretty hairy very quickly. Unfortunately, the basic set of Un*x utilities that process text data is just not powerful/flexible enough and usually each tool has some ridiculous custom syntax to learn, all of them different.

IEnumerable and LINQ

3 minute read Published:

I cannot stress enough the importance of knowing how LINQ queries work when they are based on an IEnumerable source. When one defines a query based on an IEnumerable source, the query variable represents just that: the query, NOT the results of enumerating the query. Each time you enumerate over the query object, you are calculating the results of that query on-demand. There is no caching of results. The LINQ IEnumerable implementation makes no assumptions that enumerating the same query twice in a row will produce the same results and so it let’s you do so without any qualms.