Programming

Shorten Your Linq Expressions

Posted on

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? […]

Programming

Get Argument Values From Linq Expression

Posted on

If you even find yourself unpacking an expression in C#, you might find this useful. I found myself in need of obtaining a list of argument values from within an Expression expression that sometimes had chained method calls. For example, I needed to be able to get the arguments from all of the following… SomeMethod(() […]

Programming

Real Linq Style Operations Using ECMAScript 6

Posted on

There have been a few attempts to create versions of .NET’s LINQ extensions to JavaScript and TypeScript, but most of them involve operating on an array and returning an array. To be clear, it involves evaluating the result of the expression immediately and giving back the whole result immediately. This isn’t really analogous for LINQ, […]