David Hayden [MVP C#]

Sponsors

The Lounge

News

  • CodeBetter.Com Home

Other Links

Teas

Patterns & Practices

Florida .NET Developer

Book Reviews

Tampa ASP.NET MVC Developer Group

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
T4 Templates for Code Generation Screencast

T4 Template ScreencastI put together a quick screencast showing how to leverage T4 Templates in Visual Studio 2008 for Code Generation:

I show step-by-step how to create a simple T4 Template and then how to generate various Entity, Data Access Object, and Factory Classes using more advanced T4 Templates that one might use to create a simple custom data access layer. I have seen other screencasts that have used SQL Server Management Objects, but in my case I use database schema related functionality in good 'ol ADO.NET. Although I wouldn't use this technique to build a data access layer given all the cool code generators and O/R Mappers, it is a pretty decent way to show the possibilities with T4 Templates.

I picked up a new iPhone 3G the other day and absolutely love it, so I also created a version of the screencast that you can download and play on the iPhone. In fact, several of the more recent Unity and Enterprise Library 4.0 Screencasts now have an iPhone version.

If you are interested in some of the ADO.NET techniques I used in the screencast to get database schema information, check out the show notes with links to various tutorials.

I hope the screencast is useful.


Posted Tue, Jul 22 2008 3:55 PM by David Hayden

[Advertisement]

Comments

Steven J. Ackerman wrote re: T4 Templates for Code Generation Screencast
on Tue, Jul 22 2008 5:25 PM

Thanks David. I'm going to be out of town for the August SarasotaDevs meeting, which is on this subject. I think that you gave a great overview of this technology.

joshka wrote re: T4 Templates for Code Generation Screencast
on Wed, Jul 23 2008 6:48 AM

You say "go ahead" too much... ;) I counted 6 times in the first 10 minutes.

David Hayden wrote re: T4 Templates for Code Generation Screencast
on Wed, Jul 23 2008 10:09 AM

Thanks, Steven. I didn't realize T4 Templates were the next subject at our meeting. You will be missed.

David Hayden wrote re: T4 Templates for Code Generation Screencast
on Wed, Jul 23 2008 10:15 AM

Joshka,

I tend to find some useless phrase and repeat it during these screencasts. Normally it is "actually" or "essentially" so consider "go ahead" a refreshing change :) As try as I might to not do it, the nervous tick always comes out.

Hopefully it is not too distracting...

Damien Guard wrote re: T4 Templates for Code Generation Screencast
on Wed, Jul 23 2008 1:58 PM

I just posted a T4 template to build a LINQ to SQL DataContext and associated entities from a DBML allowing you to effectively customize the code generation phase.

damieng.com/.../linq-to-sql-t4-template-reloaded

[)amien

joshka wrote re: T4 Templates for Code Generation Screencast
on Wed, Jul 23 2008 7:26 PM

Hehe, no it was not too distracting. Thanks for the screencast.