Away for a week

Brian Harry


Sorry you haven’t heard from me for a while.  It’s been busy.  I just got back from Redmond (spent all last week there).  I was wrapping up a “special project”.  Given my background both in CLR and in databases, I was asked to spend a few weeks looking at Linq, Linq to SQL and Linq to Entities and give some feedback.  Before that I’d really been largely ignoring what was going on there – other than a vague understanding of the problem space. Wow!  It’s really pretty cool stuff.  When it comes to SQL, I tend to be very server focused.  In TFS, the vast majority of our SQL is in sprocs on the server and very little is dynamic SQL generated by the mid tier.  Today, Linq’s place is really in the later category.  I’ve got to tell you though that when you are in that later category, Linq has a lot to bring to the table. I spent a little bit of time playing around with the Linq & ADO.NET CTPs and wrote some pretty cool programs.  The abstraction of database operations as filters over enumerations and integration with the CLR type system are really powerful.  It allows you to do amazing things with virtually no code.  The new Linq syntax, allows for intellisense, and a level of compile time validation that are really compelling.  Getting runtime errors from improperly formed SQL strings has always been a pain and Linq can make that mostly a thing of the past. For those who haven’t see Linq before, here is a very simple example that prints all of the commands longer than 60 seconds (60,000,000 microseconds :)) from a TFS activity log: var commands = from command in db.tbl_Command
               where command.ExecutionTime > 60000000
               select command;

foreach (tbl_Command command in commands)
    Console.WriteLine(“{0} – {1}“, command.Application, command.Command);
}   In case you are curious, that roughly compiles to this: MethodInfo get_ExecutionTime = typeof(tbl_Command).GetProperty(“ExecutionTime“).GetGetMethod();
ParameterExpression expression1 = Expression.Parameter(typeof(tbl_Command), “command“);
IQueryable<tbl_Command> queryable1 = Queryable.Where<tbl_Command>(
                                            Expression.Lambda<Func<tbl_Command, bool>>(
                                                    Expression.Property(expression1, get_ExecutionTime),
                                                    Expression.Constant((long) 0x3938700, typeof(long))),
                                                new ParameterExpression[] { expression1 }));
foreach (tbl_Command command1 in queryable1)
      Console.WriteLine(“{0} – {1}“, command1.Application, command1.Command);
} I’ve got a bunch of new news in my queue to write about. I’ll try to do several posts in the next few days to let you know about it. Thanks,



Comments are closed. Login to edit/delete your existing comments