ASP.NET IronPython

October 2009 - Posts

Using C# Dynamic to simplify ADO.NET Data Access
Recently, I started playing around with C# dynamic, and blogged how it could be used to call static class members late bound .  Today, I was talking to Phil Haack , who I think had talked to ScottGu , and he mentioned that it would be cool to use dynamic to simplify data access when you work directly with SQL query.  So I thought I’d play around with that, and it didn’t take much code to make it work nicely. So the scenario is that you’re not using any fancy O/R mapper like LINQ to SQL or Entity Framework, but you’re directly using ADO.NET to execute raw SQL commands.  It’s not something that I would personally do, but there are a lot of folks who prefer this over the higher level data access layers. So let’s look at an example...
Using C# dynamic to call static members
By now, you’ve probably heard that C# 4.0 is adding support for the dynamic keyword, which introduces some aspects of dynamic languages to C#.  I had not had a chance to really try it, but recently I was reading Bertrand Le Roy’s post on the topic, and was sort of looking for a good opportunity to use it. Today, I found a scenario which I thought it would work great for, but it turned out not to be supported out of the box! The scenario is to call static class members using dynamic.  That probably sounds crazy, so let’s look at an example.  Say you have these two classes: public class Foo1 { public static string TransformString(string s) { return s.ToLower(); } public static string MyConstant { get { return "Constant from...
T4MVC 2.4.04 update: MVC 2 support, new settings, cleanup, fixes
To get the latest build of T4MVC: Go to download page on CodePlex   Though I haven’t blogged for a while about T4MVC, I’ve been making a few minor updates and only sent notification via Twitter.  Now, I have a few things that are worth discussing in a little more detail.  Note that you can see the complete list of changes from version to version in the readme.txt file that comes with it.  BTW, I used to have all this revision information directly in the .tt file, but it was getting a little long so I moved it to the readme. The changes described below were added between version 2.4.00 and 2.4.04.   MVC 2 Preview 2 support The most interesting things to many people is that I just made a fix to allow T4MVC to work on MVC...
More Posts