Get the Most out of WebGrid in ASP.NET MVC

My first MSDN Magazine article is up: Get the Most out of WebGrid in ASP.NET MVC. So, if you want to find out how to make the WebGrid component from WebMatrix fit in with ASP.NET MVC then take a peek…. http://msdn.microsoft.com/en-us/magazine/hh288075.aspx. Thanks to Carl Nolan and Simon Ince for reviewing the article 🙂 **UPDATE – the…

15

Cheating at Scrabble with LINQ to Objects

I read an interesting post on Eric Lippert’s blog recently where he was using LINQ to Objects to find possible words from a set of letters in Scrabble (he wasn’t actually cheating – that just makes for a more interesting title!). Eric made a great follow-up post that highlights the need for both defining performance…

4

Creating database connections with Unity – part 2

Last time we looked at how to set up the configuration file so that Unity would wire up an object that took an IDbConnection parameter in its constructor. Whilst the solution works, it is easy for the various connection strings to become buried away in the Unity configuration. Also, the application configuration file already has…

3

Creating database connections with Unity

I was adding dependency injection to an existing project and opted to use Unity configured via the application configuration file. As I was running through the configuration, I hit a type that required a  database connection which it took in as an IDbConnection reference in the constructor so I added the following config under the…

4

DataServiceQuery<T>.Expand

ADO.Net Data Services allows you to expose your LINQ To Entities model (or LINQ To SQL model, or even your custom IQueryable model) via a RESTful API with minimal coding. For example, if you’re working with the Northwind database you can use the URL http://server/Service.svc/Customers(‘ALFKI’)/Orders to retrieve the orders for customer ALFKI. This simplicity makes…

7

Improving ObjectQuery<T>.Include

** UPDATE: There’s a bug in the code below – see this post for the update! One of the great features of LINQ To SQL and LINQ To Entities is that the queries you write are checked by the compiler, which eliminates typing errors in your query. Unfortunately, the ObjectQuery<T>.Include function (which is used to…

14

A closer look at yield – part 3

This was only going to be two posts, but after my last post I’d been mulling over a post that looks at the compiler generated code in a more general way. Whilst catching up on blogs posts this morning I saw that Raymond Chen has written a blog post entitled ‘The implementation of iterators in…

0

A closer look at yield – part 2

In part 1, we took a quick tour of the yield keyword. In this post we’re going to have a look at the code that the compiler generates for us when we use yield. We’ll return to the first example from last time and insert a Console.WriteLine before the yield return statement: private static readonly…

1

Using let in LINQ to Objects – Part 3

  This is a follow-up to my two previous posts on the let keyword Using let in LINQ to Objects Using let in LINQ to Objects – Part 2 The real reason for this post is to link to a great post that K.Scott Allen has just published : Optimizing LINQ Queries. In his post,…

0

A closer look at yield

The yield keyword in C# is pretty powerful and expressive, but it doesn’t seem to be very widely known about. In this post we’ll take a quick look at what yield does and then I’ll post a follow-up that looks at what the compiler generates for you. Let’s start by looking at a simple (and…

3