Softwire Blog


Grouping with LINQ


20 August 2012, by

previous article in series

When I was first starting out with LINQ, the method I had most trouble getting my head round was GroupBy. So I wanted to finish this series of posts with a quick how-to on grouping, in case others find the same problem.

In SQL, GROUP BY seems so straightforward. Somehow in LINQ it seems to contrive to cause problems though. But it’s easy when you know how.

(more…)

Don’t be too lazy – LINQ’s lazy evaluation gotchas


13 August 2012, by

previous article in series

Having discussed how to take advantage of lazy evaluation in LINQ, it only seems right to discuss some of the surprises this might cause you. I’ve picked out a few examples from my own experience of where understanding what’s going on behind the scenes is important to avoid falling into a trap.

(more…)

Lazy LINQing


6 August 2012, by

previous article in series

This post looks at one reasonably important aspect of how LINQ works under the hood – lazy evaluation.

(more…)

Simplify with LINQ


30 July 2012, by

Using LINQ to simplify your code

previous article in series

LINQ is all about manipulating data. But actually, so is a remarkably large amount of programming. We’ve already looked at some things you can do with your list of beers using LINQ, but actually if you go back to the example I used to introduce generics, that’s all about manipulating data too:

(more…)

An introduction to LINQ


23 July 2012, by

previous article in series

This series of posts is about Language Integrated Query (LINQ, pronounced “link”) – a set of libraries providing a means of querying data in C#. It is intended very much as a beginner’s guide, although those who have a basic knowledge of LINQ but don’t have a full understanding of its principles might still find some points of interest.

(more…)

Generic collections in C#


16 July 2012, by

Over the next few weeks I’ll be publishing a short series of posts introducing Language Integrated Query (LINQ). However to use LINQ well it’s important to have a basic understanding of Generics, so my first post covers this topic. For nostalgia value, I’ve included a little bit of history from the heady days of .NET 1.1, and some advice for anyone who’s coming back to .NET programming having not used it since those days.

(more…)

Staying DRY with LINQ to Entities


10 February 2012, by

A common problem with LINQ to Entities is that it can often lead to code repetition. This post explains why and when this happens, and how to get around it using LinqKit.

In this article I’m going to assume that you have at least a passing familiarity with the concept of DRY (Don’t Repeat Yourself) and why it’s a good thing, and with LINQ to Entities.

(more…)