skip to the main content area of this page
Patterns and Practices

 

LINQ To SQL Code Generation Using T4 Templates - T4 Template Tutorials


After watching the T4 Templates in Visual Studio for Code Generation Screencast, you can check out Damien Guard's LINQ To SQL T4 Templates that produce similar output to the LINQ To SQL Classes Visual Studio 2008 Add-In.

The LINQ To SQL T4 Templates don't generate everything that the LINQ To SQL Visual Designer or SQLMetal generate in terms of code, but if you are interested in how to generate code with T4 Templates, the LINQ To SQL T4 Templates will get you started.

 

LINQ To SQL T4 Templates

 

You can note in the Visual Studio Solution Explorer how there are two T4 Templates:

  • Northwind.tt which generates the DataContext and Entity Classes that I renamed to match the name of the LINQ To SQL DBML File.
  • L2St4.tt which is a helper T4 Template File.

Before you start doing code generation with T4 Templates in Visual Studio, make sure you download the T4 Editor which will help you in the development and editing of T4 Templates.

Check out the T4 Editor.

Download Damien's LINQ To SQL T4 Templates here.

Click here to find all the T4 Tutorials and Samples on PnPGuidance.

 


Tags: T4


RSS Syndication RSS Syndication

Twitter Microsoft .NET Web Developer Follow me on Twitter

Google+ Microsoft .NET Web Developer Follow me on Google+


Topics



 

Recent Links