Steve Fenton


You can subscribe to the linq tag micro-feed.

De-mystifying Linq

This post is a summary of the De-mystifying Linq session I ran on 24th January. The examples below were just on-the-spot examples created during the talk… The System.Linq namespace can seem a bit like magic, but it can be useful to demystify it by showing that it is actually just some C# code that we […]

Linq style mapping for single objects

Linq is not just the go-to .NET library for handling IEnumerable data sources, it’s the inspiration for many successful and unsucessful attempts to reproduce the style in other languages. When you have a class full of Linq and you find yourself wanting to simply map a single object to something else, you’ll find yourself writing […]

Shorten your Linq expressions

There is an interesting style of Linq expression that I am seeing a lot in code, including open source projects. It isn’t a big deal, but it damages readability. It looks like this: var result = someEnumerable.Where(e => e.IsCondition).FirstOrDefault(); var result = someEnumerable.Where(e => e.IsCondition).SingleOrDefault(); var result = someEnumerable.Where(e => e.IsCondition).Count(); Can you spot it? […]