CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

David Hayden [MVP C#]

         .NET Tutorials, Patterns, and Practices

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.



Comments

Steven J. Ackerman said:

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.

# July 22, 2008 5:25 PM

joshka said:

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

# July 23, 2008 6:48 AM

David Hayden said:

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

# July 23, 2008 10:09 AM

David Hayden said:

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...

# July 23, 2008 10:15 AM

Damien Guard said:

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

# July 23, 2008 1:58 PM

joshka said:

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

# July 23, 2008 7:26 PM
Check out Devlicio.us!

Our Sponsors

This Blog

Syndication

News

CodeBetter.Com Home