Improving ObjectQuery<T>.Include – Updated

Having spent some time using the sample from my previous post on ObjectQuery.Include, I’ve encountered a bug! It turns out that the code generates the wrong include string for context.Customers.Include(c => c.Order.SubInclude(o=>o.OrderDetail)) The fix for this is a small change to the BuildString method to recurse up the MemberExpression if necessary. The updated code is…

7

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

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

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

Using let in LINQ to Objects – Part 2

In my previous post, I looked at what the compiler generates when you use the let keyword in LINQ to Objects. This is a follow-up post slanted towards performance. To this end, I set up four tests: static void TestBaseline() { var q = from c in Customer.AllCustomers select c; int count = q.Count(); }…

5

Using let in LINQ to Objects

I’ve been delving into LINQ to Objects recently (and enjoying it), but had missed the ‘let’ keyword. A colleague Rupert Benbrook(http://phazed.com) and I had been chatting about how to solve a particular issue using LINQ to Objects and he sent me a follow-up email with some code that used the ‘let’ keyword and I thought…

9