<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://community.codesmithtools.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tutorials</title><link>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/default.aspx</link><description /><dc:language>en</dc:language><generator>Telligent Community (Build: 5.5.133.9594)</generator><item><title>Generating Custom Exceptions in Visual Studio 2005</title><link>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/04/06/12322.aspx</link><pubDate>Thu, 06 Apr 2006 21:47:00 GMT</pubDate><guid isPermaLink="false">829aebef-9208-4531-832e-1f916c1e97cb:12322</guid><dc:creator>pwelter34</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/rsscomments.aspx?WeblogPostID=12322</wfw:commentRss><comments>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/04/06/12322.aspx#comments</comments><description>&lt;H2&gt;Generating Custom Exceptions in Visual Studio 2005&lt;/H2&gt;
&lt;H3&gt;Overview&lt;/H3&gt;
&lt;P&gt;The following quick tutorial will demonstrate the use of CodeSmith with Visual Studio.&amp;nbsp; &lt;/P&gt;
&lt;H3&gt;Sample Project &lt;/H3&gt;
&lt;P&gt;This tutorial will use a simple Windows Form application that raises a custom exception.&amp;nbsp; The applications needs two custom exceptions called NameNotFoundException and ValidationException. The custom exception classes are generated by CodeSmith.&lt;/P&gt;
&lt;H3&gt;Exception Template&lt;/H3&gt;
&lt;P&gt;&lt;BR&gt;The Custom Exception template generates an exception class that implements the recommend pattern.&amp;nbsp; The template has the following properties.&lt;/P&gt;
&lt;TABLE&gt;

&lt;TR&gt;
&lt;TD&gt;Accessibility&lt;/TD&gt;
&lt;TD&gt;The accessibility of the class to be generated.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;Arguments&lt;/TD&gt;
&lt;TD&gt;List of exception argument properties. Example FileName=string&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ArgumentMessage&lt;/TD&gt;
&lt;TD&gt;The string format message to use in the ToString method of this exception when there are custom arguments. Example: File '{0}' Not Found.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;BaseClass&lt;/TD&gt;
&lt;TD&gt;The name of the Exception class to inherit.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ClassName&lt;/TD&gt;
&lt;TD&gt;The name of the Exception class to be generated.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ClassNamespace&lt;/TD&gt;
&lt;TD&gt;The namespace to contain this class.&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;ErrorCode&lt;/TD&gt;
&lt;TD&gt;The HResult Error Code this exception represents.&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;H3&gt;Running Template&lt;/H3&gt;
&lt;TABLE&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;IMG height=338 alt="Figure 1 – Save CodeSmith Property Set XML" hspace=3 src="/photos/tutorials/images/12319/original.aspx" width=337 border=0&gt;&lt;/TD&gt;
&lt;TD&gt;The first thing you need to do to use the template in Visual Studio is to create an XML file that contains the property set information.&amp;nbsp; The easiest way to do that is to run CodeSmith, set the property values, and Save Property Set XML.&amp;nbsp; (See Figure 1)&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;
&lt;H3&gt;Integrating into Visual Studio Project&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;The next step is to include the property set XML file into the Visual Studio project.&amp;nbsp; Then edit the XML file to include a &amp;lt;template path="" /&amp;gt; element. Next wrap the &amp;lt;propertySet&amp;gt; element in a &amp;lt;propertySets&amp;gt; element. &lt;/P&gt;
&lt;P&gt;The sample application also needs a custom validation exception.&amp;nbsp; We can modify the XML file to also generate the ValidationException. To do this, you need to add another &amp;lt;propertySet&amp;gt; element that contains a &amp;lt;property&amp;gt; element for ClassName and ClassNamespace.&lt;/P&gt;
&lt;P&gt;The XML file should look something like this when done.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;codeSmith&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;!-- template needed for CodeSmith Custom Tool --&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;template&lt;/SPAN&gt; &lt;SPAN&gt;path&lt;/SPAN&gt;&lt;SPAN&gt;="..\CustomException.cst"&lt;/SPAN&gt; &lt;SPAN&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;propertySets&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;!-- NameNotFoundException, setting all properties--&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;propertySet&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="Accessibility"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;Public&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="BaseClass"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;Exception&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ClassName"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;NameNotFoundException&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ErrorCode"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;-2146232832&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="Arguments"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
        &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;item&lt;/SPAN&gt; &lt;SPAN&gt;key&lt;/SPAN&gt;&lt;SPAN&gt;="Name"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;string&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;item&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ClassNamespace"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;CodeSmith.Tutorial.VisualStudio&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ArgumentMessage"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;Name '{0}' Not Found.&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;propertySet&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;!-- ValidationException, using default properties --&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;propertySet&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ClassName"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;ValidationException&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
      &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt; &lt;SPAN&gt;name&lt;/SPAN&gt;&lt;SPAN&gt;="ClassNamespace"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;CodeSmith.Tutorial.VisualStudio&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;property&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;propertySet&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;propertySets&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;codeSmith&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;H3&gt;Running the Custom Tool&lt;/H3&gt;
&lt;P&gt;
&lt;TABLE&gt;

&lt;TR&gt;
&lt;TD&gt;&lt;IMG alt="Figure 2 - Custom Tool property" hspace=3 src="/photos/tutorials/images/12485/original.aspx" border=0&gt;&lt;/TD&gt;
&lt;TD&gt;To use the CodeSmith custom tool to run the template, you need to set the Custom Tool property on the XML file. To do this, select the XML file in the Solution Explorer.&amp;nbsp; Then set the Custom Tool property in the properties window to CodeSmithGenerator.&amp;nbsp;&amp;nbsp; (See Figure 2) 
&lt;P&gt;You can now right click on the XML file and select Run Custom Tool.&amp;nbsp; This will generate the new class file that is the result of running the template.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;&lt;/P&gt;
&lt;H3&gt;Running in the MSBuild BeforeBuild Target&lt;/H3&gt;
&lt;P&gt;CodeSmith also includes a MSBuild task that can be used to run templates.&amp;nbsp; One way to you can use this task in your project is to edit the Visual Studio 2005 project file. First you'll need to add an import for the CodeSmith.Targets file.&amp;nbsp; Next, you can use the built in target called BeforeBuild that gets called before the project is compiled.&amp;nbsp; In that target, add the &amp;lt;CodeSmith PropertySetFile="" /&amp;gt; element.&amp;nbsp; The following project file fragment is an example of what you need to add.&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Project&lt;/SPAN&gt; &lt;SPAN&gt;DefaultTargets&lt;/SPAN&gt;&lt;SPAN&gt;="Build"&lt;/SPAN&gt; &lt;SPAN&gt;xmlns&lt;/SPAN&gt;&lt;SPAN&gt;="http://schemas.microsoft.com/developer/msbuild/2003"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;!-- Add at bottom of Project File --&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Import&lt;/SPAN&gt; &lt;SPAN&gt;Project&lt;/SPAN&gt;&lt;SPAN&gt;="$(MSBuildExtensionsPath)\CodeSmith\CodeSmith.Targets"&lt;/SPAN&gt;&lt;SPAN&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;Target&lt;/SPAN&gt; &lt;SPAN&gt;Name&lt;/SPAN&gt;&lt;SPAN&gt;="BeforeBuild"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;CodeSmith&lt;/SPAN&gt; &lt;SPAN&gt;PropertySetFile&lt;/SPAN&gt;&lt;SPAN&gt;="Exceptions.xml"&lt;/SPAN&gt; &lt;SPAN&gt;OutputFile&lt;/SPAN&gt;&lt;SPAN&gt;="Exceptions.cs"&lt;/SPAN&gt; &lt;SPAN&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;Target&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN&gt;Project&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;/PRE&gt;
&lt;P&gt;Now, when you start a build of the project, CodeSmtih will run the template before the project is compiled.&lt;/P&gt;
&lt;H3&gt;References &lt;/H3&gt;
&lt;UL&gt;
&lt;LI&gt;CodeSmith - &lt;A href="http://www.codesmithtools.com/"&gt;http://www.codesmithtools.com/&lt;/A&gt; 
&lt;LI&gt;Custom Exception Template - &lt;A HREF="/files/9/templates/entry12291.aspx"&gt;http://community.codesmithtools.com/files/9/templates/entry12291.aspx&lt;/A&gt; 
&lt;LI&gt;Microsoft Visual Studio 2005 - &lt;A href="http://msdn.microsoft.com/vstudio/"&gt;http://msdn.microsoft.com/vstudio/&lt;/A&gt; &lt;/LI&gt;&lt;/UL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.codesmithtools.com/aggbug.aspx?PostID=12322" width="1" height="1"&gt;</description><enclosure url="http://community.codesmithtools.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-00-01-23-22/CodeSmith.Tutorial.VisualStudio.zip" length="39380" type="application/x-zip-compressed" /></item><item><title>Building a template to generate stored procedures</title><link>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/02/15/StoredProcedures.aspx</link><pubDate>Wed, 15 Feb 2006 21:07:00 GMT</pubDate><guid isPermaLink="false">829aebef-9208-4531-832e-1f916c1e97cb:9810</guid><dc:creator>ejsmith</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/rsscomments.aspx?WeblogPostID=9810</wfw:commentRss><comments>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/02/15/StoredProcedures.aspx#comments</comments><description>&lt;H2&gt;Download Links&lt;/H2&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="http://www.codesmithtools.com/"&gt;Download a free 30 day trial of CodeSmith Professional&lt;/A&gt; 
&lt;LI&gt;&lt;A href="/downloads/codesmith_sp.zip"&gt;Download sample templates&lt;/A&gt; 
&lt;LI&gt;&lt;A href="/blogs/videotutorials/archive/2006/02/16/StoredProcedures.aspx"&gt;Watch a video presentation of this tutorial&lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;
&lt;H2&gt;Introduction&lt;/H2&gt;
&lt;P&gt;CodeSmith is a template based code generator for any ASCII language. It uses a syntax very similar to ASP.NET. This tutorial describes the process of building a template to generate SELECT/INSERT/UPDATE/DELETE stored procedures.&lt;/P&gt;
&lt;H2&gt;Getting Started&lt;/H2&gt;
&lt;P&gt;All templates must include a &lt;CODE&gt;CodeTemplate&lt;/CODE&gt; directive like this one.&lt;/P&gt;&lt;PRE&gt;&amp;lt;%@ CodeTemplate Language="C#" TargetLanguage="T-SQL"
  Description="Generates SELECT/INSERT/UPDATE/DELETE stored procedures." %&amp;gt;&lt;/PRE&gt;
&lt;P&gt;Here we tell CodeSmith that we plan to use C# as our template language, we plan to generate code for the T-SQL language and we also provide a description for what the template does. The Language attribute tells CodeSmith what language we will use to write our template code and can be C# (C#, CS, CSharp), VB.NET (VB, VBS, VisualBasic, VBScript) or JScript.NET (JS, JScript, JavaScript). The TargetLanguage attribute can be anything, but setting it to T-SQL will cause the template to be grouped together with other T-SQL templates in CodeSmith Explorer's target language view. The TargetLanguage attribute is also used to syntax highlight the static content in a template in CodeSmith Studio. And finally, the &lt;CODE&gt;Description&lt;/CODE&gt; attribute allows us to provide a brief description of the template that will be shown in CodeSmith Explorer.&lt;/P&gt;
&lt;P&gt;In order to be able to generate code based on a database table, the template must somehow know about this table. CodeSmith allows us to provide this contextual information to the template by specifying &lt;CODE&gt;Property&lt;/CODE&gt; directives.&lt;/P&gt;&lt;PRE&gt;&amp;lt;%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema"
  Category="Context"
  Description="Table that the stored procedures should be based on." %&amp;gt;&lt;/PRE&gt;
&lt;P&gt;The &lt;CODE&gt;Name&lt;/CODE&gt; attribute tells CodeSmith what we want the property to be named in our template. This is the name that we will use to access the property in our template. The &lt;CODE&gt;Type&lt;/CODE&gt; attribute tells CodeSmith what type our new property should be. This can be any .NET type that has a designer (most built-in .NET types have designers). In this case we use a type from CodeSmith's included Schema Explorer library. This type allows us to pick a table from a database and will then tell us anything we want to know about that table. We will use this information to drive our template. The &lt;CODE&gt;Category&lt;/CODE&gt; attribute simply allows us to put our new property into a group of properties with the same category. And lastly, the &lt;CODE&gt;Description&lt;/CODE&gt; attribute allows for a brief description of what the property will be used for in the template. &lt;/P&gt;
&lt;P&gt;CodeSmith allows the flexibility for anyone to create a new .NET type and, as long as they also create a designer for that type, it can be used in your templates. The included Schema Explorer library is an example of this flexibility. CodeSmith does not know anything about Schema Explorer, so we must instruct our template on how to find the &lt;CODE&gt;SchemaExplorer.TableSchema&lt;/CODE&gt; type. We do this by adding an &lt;CODE&gt;Assembly&lt;/CODE&gt; directive. &lt;/P&gt;&lt;PRE&gt;&amp;lt;%@ Assembly Name="SchemaExplorer" %&amp;gt;&lt;/PRE&gt;
&lt;P&gt;This just tells our template that we plan to make use of code found in an external assembly. The &lt;CODE&gt;Name&lt;/CODE&gt; attribute must correspond to an assembly (without the .dll extension) in either the same directory as the template or in the same directory as the CodeSmith executable.&lt;/P&gt;
&lt;H2&gt;Writing Our Template &lt;/H2&gt;
&lt;P&gt;Now that we have setup everything that we will need to base our template on, we can begin writing our template content. It is always best to start with an example of what you want the output to look like. Here is an example UPDATE stored procedure for the Northwind..Products table.&lt;/P&gt;&lt;PRE&gt;-----------------------------------------------------------------
-- Date Created: Thursday, January 02, 2003
-- Created By:   Eric J. Smith
-----------------------------------------------------------------

CREATE PROCEDURE dbo.UpdateProducts
  @ProductID int,
  @ProductName nvarchar(40),
  @SupplierID int,
  @CategoryID int,
  @QuantityPerUnit nvarchar(20),
  @UnitPrice money,
  @UnitsInStock smallint,
  @UnitsOnOrder smallint,
  @ReorderLevel smallint,
  @Discontinued bit
AS

UPDATE [Products] SET
  [ProductName] = @ProductName,
  [SupplierID] = @SupplierID,
  [CategoryID] = @CategoryID,
  [QuantityPerUnit] = @QuantityPerUnit,
  [UnitPrice] = @UnitPrice,
  [UnitsInStock] = @UnitsInStock,
  [UnitsOnOrder] = @UnitsOnOrder,
  [ReorderLevel] = @ReorderLevel,
  [Discontinued] = @Discontinued
WHERE
  [ProductID] = @ProductID&lt;/PRE&gt;
&lt;P&gt;Now we must begin to make this into a dynamic template based on our &lt;CODE&gt;SourceTable&lt;/CODE&gt; property. Let's start with a simple change to make the Date Created comment dynamic. &lt;/P&gt;&lt;PRE&gt;-- Date Created: &amp;lt;%= DateTime.Now.ToLongDateString() %&amp;gt;&lt;/PRE&gt;
&lt;P&gt;Just like in ASP.NET we use the &amp;lt;%= %&amp;gt; construct. When the template is executed, this expression will be expanded to the current date in long date form. &lt;/P&gt;
&lt;P&gt;Now we need to figure out how to build our list of parameters for the stored procedure. We will derive this list from the information in the &lt;CODE&gt;SourceTable.Columns&lt;/CODE&gt; property. This property is a collection of &lt;CODE&gt;ColumnSchema&lt;/CODE&gt; objects that represent each column in the selected table. Here is a simple example of outputing each column in the table. &lt;/P&gt;&lt;PRE&gt;&amp;lt;% for (int i = 0; i &amp;lt; SourceTable.Columns.Count; i++) { %&amp;gt;
  &amp;lt;%= SourceTable.Columns&amp;#91;i&amp;#91;.Name %&amp;gt;
  &amp;lt;% if (i &amp;lt; SourceTable.Columns.Count - 1) { %&amp;gt;,&amp;lt;% } %&amp;gt;
  &amp;lt;% } %&amp;gt;&lt;/PRE&gt;
&lt;P&gt;In this example we use the &amp;lt;% %&amp;gt; construct to add logic to the template. What language you selected in the &lt;CODE&gt;Language&lt;/CODE&gt; attribute from above will determine the language that you will need to use for your template logic. In our example, we have specified C# as our language so that is what we use here. The output from this example when the selected table is Northwind..Products looks like: &lt;/P&gt;&lt;PRE&gt;ProductID,
  ProductName,
  SupplierID,
  CategoryID,
  QuantityPerUnit,
  UnitPrice,
  UnitsInStock,
  UnitsOnOrder,
  ReorderLevel,
  Discontinued&lt;/PRE&gt;
&lt;P&gt;This is a nice start, but we have a little more work to do before this looks like a real set of parameters. Since the logic for each parameter will be somewhat complex, we should go ahead and create a method to output each parameter. To do this we will need to use a &amp;lt;script&amp;gt; block. Again, this is just like ASP.NET. &lt;/P&gt;&lt;PRE&gt;&amp;lt;script runat="template"&amp;gt;
public string GetSqlParameterStatement(ColumnSchema column)
{
  string param = "@" + column.Name + " " + column.NativeType;

  switch (column.DataType)
  {
    case DbType.Decimal:
    {
      param += "(" + column.Precision + ", " + column.Scale + ")";
      break;
    }
    default:
    {
      if (column.Size &amp;gt; 0)
      {
        param += "(" + column.Size + ")";
      }
      break;
    }
  }
  return param;
}
&amp;lt;/script&amp;gt;&lt;/PRE&gt;
&lt;P&gt;Instead of setting the &lt;CODE&gt;runat&lt;/CODE&gt; attribute to server like we would do in ASP.NET, we set it to template. This causes the CodeSmith compiler to process this script block as code instead of passing it on as part of the template content. This distinction allows the creation of templates that output ASP.NET code with server &amp;lt;script&amp;gt; blocks. Also, on that note, I should mention that you will need to escape your ASP.NET constructs if you plan to have them output in a template (ie. &amp;lt;%% expression %%&amp;gt; results in this output &amp;lt;% expression %&amp;gt;).&lt;/P&gt;
&lt;P&gt;Here is a look at our final code for the UPDATE stored procedure:&lt;/P&gt;&lt;PRE&gt;-----------------------------------------------------------------
-- Date Created: &amp;lt;%= DateTime.Now.ToLongDateString() %&amp;gt;
-- Created By:   Generated by CodeSmith
-----------------------------------------------------------------

CREATE PROCEDURE dbo.Update&amp;lt;%= SourceTable.Name %&amp;gt;
  &amp;lt;% for (int i = 0; i &amp;lt; SourceTable.Columns.Count; i++) { %&amp;gt;
  &amp;lt;%= GetSqlParameterStatement(SourceTable.Columns) %&amp;gt;
  &amp;lt;% if (i &amp;lt; SourceTable.Columns.Count - 1) { %&amp;gt;,&amp;lt;% } %&amp;gt;
  &amp;lt;% } %&amp;gt;
AS

UPDATE [&amp;lt;%= SourceTable.Name %&amp;gt;] SET
  &amp;lt;% for (int i = 0; i &amp;lt; SourceTable.NonPrimaryKeyColumns.Count; i++) { %&amp;gt;
  [&amp;lt;%= SourceTable.NonPrimaryKeyColumns&amp;#91;i&amp;#91;.Name %&amp;gt;] = @
  &amp;lt;%= SourceTable.NonPrimaryKeyColumns&amp;#91;i&amp;#91;.Name %&amp;gt;
  &amp;lt;% if (i &amp;lt; SourceTable.NonPrimaryKeyColumns.Count - 1) { %&amp;gt;,&amp;lt;% } %&amp;gt;
  &amp;lt;% } %&amp;gt;
WHERE
  &amp;lt;% for (int i = 0; i &amp;lt; SourceTable.PrimaryKey.MemberColumns.Count; i++) { %&amp;gt;
  &amp;lt;% if (i &amp;gt; 0) { %&amp;gt;AND &amp;lt;% } %&amp;gt;
  [&amp;lt;%= SourceTable.PrimaryKey.MemberColumns&amp;#91;i&amp;#91;.Name %&amp;gt;] =
  @&amp;lt;%= SourceTable.PrimaryKey.MemberColumns&amp;#91;i&amp;#91;.Name %&amp;gt;
  &amp;lt;% } %&amp;gt;&lt;/PRE&gt;
&lt;H2&gt;Generate The Code&lt;/H2&gt;
&lt;P&gt;Now that you have built your template, you can use CodeSmith to execute it and see the results. You can execute the template by double-clicking the codesmith_sp.cst file that is included in the download at the top of this page. You will then see a screen that looks like this:&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp2.png"&gt; 
&lt;P&gt;Click the elipses next to the SourceTable property.&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp3.png"&gt; 
&lt;P&gt;Now click the elipses next to the Data Source drop down.&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp4.png"&gt; 
&lt;P&gt;Select Add.&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp5.png"&gt; 
&lt;P&gt;Enter the Data Source information. Name can be anything but you should make it something that represents the database in your connection string since this the name that will be used to select the Data Source in the future. Provider Type can be SqlSchemaProvider or ADOXSchemaProvider. SqlSchemaProvider should be used for any SQL Server or MSDE database and ADOXSchemaProvider should be used for any other database that has an ADOX provider. The Connection String is the same as any other connection string you would specify in your application. See the SqlConnection documentation for SqlSchemaProvider and the ADODB.Connection documentation for the ADOXSchemaProvider. Here we specify the Northwind database located in the .NET SDK sample MSDE instance. These settings should work for anyone who has installed the .NET SDK QuickStart samples. Click OK once you have entered all the information. Then click Close on the Data Source Manager screen. Now you should see a list of tables in the Northwind database. Select the Products table.&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp6.png"&gt; 
&lt;P&gt;Select Generate and see the results! After you generate the code, you can click the Copy Template Output button at the top and the output will be copied to your clipboard. Another great way to generate code once you have finished building your template is using the CodeSmith Explorer window.&lt;/P&gt;&lt;IMG src="/images/StoredProcedures/codesmith_sp7.png"&gt; 
&lt;P&gt;This is the window that is displayed if CodeSmith is started with no parameters. It allows you to see all templates in a given directory. You can then drag a template to any application that supports dropping text (this includes VS.NET). When you do so the template properties window will display, you will set all required properties and when you click Generate the output will be added to wherever you dragged the template.&lt;/P&gt;
&lt;H2&gt;Conclusion&lt;/H2&gt;
&lt;P&gt;CodeSmith allows the use of templates to avoid repetative coding tasks. We used a previous version of CodeSmith in our last project and were able to generate over 60% of our code. This included generating stored procedures, business objects, collection classes, ASPX pages and codebehind files.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.codesmithtools.com/aggbug.aspx?PostID=9810" width="1" height="1"&gt;</description></item><item><title>Build a Data Access Layer in less than 15 minutes</title><link>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/02/13/nettiers.aspx</link><pubDate>Mon, 13 Feb 2006 18:16:00 GMT</pubDate><guid isPermaLink="false">829aebef-9208-4531-832e-1f916c1e97cb:9655</guid><dc:creator>ejsmith</dc:creator><slash:comments>28</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/rsscomments.aspx?WeblogPostID=9655</wfw:commentRss><comments>http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/2006/02/13/nettiers.aspx#comments</comments><description>&lt;h2&gt;Download Links&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://www.codesmithtools.com/"&gt;Download a free 30 day trial of CodeSmith Professional&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.nettiers.com/"&gt;Download latest .netTiers templates&lt;/a&gt; 
&lt;/li&gt;
&lt;li&gt;&lt;a href="http://community.codesmithtools.com/r.ashx?id=1"&gt;Watch a video presentation of this article&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In this article you will learn how to build a Data Access Layer using Microsoft&amp;rsquo;s Enterprise Library in less than 15 minutes using CodeSmith and the .netTiers Template Library. &lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CodeSmithBox.jpg" width="325" align="right" height="427" hspace="12" alt="" /&gt; The Data Access Layer, from here on out referred to as the DAL, is the layer of application functionality that encapsulates all interactions with the database. Typically this type of code is hand written and requires specialized knowledge, not only of .NET, but of the specific data access routines too. Writing the DAL code for an application is one of the most monotonous, time consuming, repetitive, and likely bug-ridden aspects of building software. &lt;/p&gt;
&lt;p&gt;For this article we&amp;rsquo;ll use the sample Northwind database in SQL Server, but these examples will work with any database. And of course, after this article you&amp;rsquo;ll no longer view writing the DAL for your application as monotonous and time consuming, but quick, easy, and simple!&lt;/p&gt;
&lt;p&gt;If you follow this article at the end you will be able to create a complete best practices Data Access Layer in just under 1 minute (the other 14 minutes are for downloading the software the first time).&lt;/p&gt;
&lt;h2&gt;Code Generation, a brief overview&lt;/h2&gt;
&lt;p&gt;Code generation, or the use of software tools to generate code, is not a new concept. In fact, code generation has been around for quite some time. In this article I&amp;rsquo;m going to use CodeSmith as the tool for generating both the code and T-SQL scripts for the DAL. &lt;/p&gt;
&lt;p&gt;CodeSmith is a developer productivity tool that enables developers to use templates to control the formatting and desired code output. Therein is the beauty of CodeSmith - software developers still retain full control over the code created through templates. Templates provide the opportunity for people to create new and interesting code reuse and generation libraries, such as the .netTiers templates used in this article.&lt;/p&gt;
&lt;h2&gt;Step 1 &amp;ndash; Setup&lt;/h2&gt;
&lt;p&gt;The first step is to get the necessary tools (CodeSmith) and templates (.netTiers). CodeSmith is a commercial developer tool, but there is a 30-day free trial we can use for the purpose of this article:&lt;/p&gt;
&lt;h2&gt;Download and Install CodeSmith&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://www.codesmithtools.com/"&gt;http://www.codesmithtools.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;CodeSmith comes with a lot of built-in templates and the next service pack will include the .netTiers templates shown in this article. &lt;/p&gt;
&lt;p&gt;Now that CodeSmith is installed, download the .netTiers template library:&lt;/p&gt;
&lt;h2&gt;Download .netTiers Template Library for CodeSmith&lt;/h2&gt;
&lt;p&gt;&lt;a href="http://www.nettiers.com/"&gt;http://www.nettiers.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;On the .netTiers site click on the &amp;quot;Latest Download&amp;quot; link in the left-column; next, click on &amp;quot;available for download&amp;quot; at the top of the page. This will take you to another page where you can download the latest Windows MSI installer.&lt;/p&gt;
&lt;p&gt;The last step is to ensure you have a SQL Server database setup and have a connection string you can use to connect to the database. &lt;/p&gt;
&lt;h2&gt;Step 2 &amp;ndash; CodeSmith&lt;/h2&gt;
&lt;p&gt;After downloading and installing CodeSmith you should be able to open it from &lt;code&gt;All Programs | CodeSmith 3.1 | CodeSmith Studio&lt;/code&gt;. Before we use the .netTiers templates you need to familiarize yourself with CodeSmith.&lt;/p&gt;
&lt;p&gt;As mentioned in the introduction, CodeSmith is a template driven code generation tool. There is a window on the right of CodeSmith called the Template Explorer. The Template Explorer provides you with a quick and easy way of accessing the templates you&amp;rsquo;ve installed or written:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_1.png" width="247" height="226" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;To explain the rest of CodeSmith we need a template. Open the Hashtable.cst template from Template Explorer by double-clicking on it.&lt;/p&gt;
&lt;p&gt;Hashtable.cst is one of the great sample templates included with CodeSmith and is used to generate strongly typed collections that use the .NET &lt;b&gt;Hashtable&lt;/b&gt; type as the base data type. Before we explain the template, let&amp;rsquo;s quickly look at another window in CodeSmith, the Properties window:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_2.png" width="236" height="161" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;The Properties window allows you to set properties for the template. When using the Hashtable.cst template we need to set some common elements such as the generated &lt;b&gt;ClassName&lt;/b&gt;, &lt;b&gt;ItemType&lt;/b&gt;, and &lt;b&gt;KeyType&lt;/b&gt;. For example, if you wanted to create a strongly typed collection of &lt;b&gt;Person&lt;/b&gt; objects accessed by an &lt;b&gt;integer&lt;/b&gt; with a class name of &lt;b&gt;PersonCollection&lt;/b&gt;, you would set the &lt;b&gt;ClassName&lt;/b&gt; to &lt;b&gt;PersonCollection&lt;/b&gt;, the &lt;b&gt;ItemType&lt;/b&gt; to &lt;b&gt;Person&lt;/b&gt;, and the &lt;b&gt;KeyType&lt;/b&gt; to &lt;b&gt;int&lt;/b&gt;. You could generate the source for this strongly typed collection now by simply clicking the Run button in CodeSmith (found on the toolbar).&lt;/p&gt;
&lt;p&gt;If you took a moment to examine the Hashtable.cst template file you might say to yourself, &amp;quot;This looks a lot like ASP.NET&amp;quot;. You&amp;rsquo;d be correct. CodeSmith templates are modeled after ASP.NET Pages and share many similar ideas. However, whereas ASP.NET Pages are used to generate HTML, CodeSmith Templates are used to generate source files or other text files.&lt;/p&gt;
&lt;p&gt;The most important thing to remember about CodeSmith is that CodeSmith does not limit your creativity by forcing you into what code is generated. Since it is template driven the code output is completely controlled by you.&lt;/p&gt;
&lt;h2&gt;Step 3 &amp;ndash; Generate the DAL&lt;/h2&gt;
&lt;p&gt;Now that you have a basic understanding of CodeSmith I want to show you the .netTiers templates.&lt;/p&gt;
&lt;p&gt;Remember, the idea behind CodeSmith is that it allows you to write code faster, with fewer defects. The .netTiers templates take that one step further and create a DAL for you that follows all the recommended Patterns &amp;amp; Practices from the team at Microsoft by the same name.&lt;/p&gt;
&lt;p&gt;First we need to add the .netTiers templates to the CodeSmith Template Explorer:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In Template Explorer click on the Open Folder icon to browse for a folder containing templates. 
&lt;/li&gt;
&lt;li&gt;Go to the folder where .netTiers was installed. On my computer this is:&lt;br /&gt;&lt;code&gt;C:\Program Files\SerialCoder\NetTiers 0.9.2 - Caribert\Templates\&lt;/code&gt; 
&lt;/li&gt;
&lt;li&gt;Once this folder is created as a shortcut in Template Explorer, expand it and select NetTiers.cst 
&lt;/li&gt;
&lt;li&gt;Now that the .netTiers templates are installed you need to configure a data source. With the NetTiers.cst template open, open the Properties window and configure a Source Database by clicking on the ellipses:&lt;br /&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_4.png" width="220" height="95" alt="" /&gt; 
&lt;/li&gt;
&lt;li&gt;This opens the Database Picker, we&amp;rsquo;re going to create a new data source so click on the ellipses in the Database Picker to open the Data Source Manager. In the screen shot below is an example of how this should look (choose a name that let&amp;rsquo;s you quickly know what database you&amp;rsquo;re working with):&lt;br /&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_5.png" width="421" height="242" alt="" /&gt; 
&lt;/li&gt;
&lt;li&gt;Test the connection to ensure it works and then back out of these dialog windows by clicking OK. Make sure the new data source is selected. 
&lt;/li&gt;
&lt;li&gt;Finally, set the EntireDatabase property to True, set the NameSpace property to Demo, and set the OutputDirectory property to the directory where you would like the generated files to be&amp;nbsp;located. You will need to create the output directory if it doesn&amp;rsquo;t exist.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Once you&amp;rsquo;ve completed these steps your property window for the NetTiers.cst template should look similar to the screenshot below (changes highlighted):&lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_6.png" width="217" height="398" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;We are not going to show anywhere near the full capabilities of .netTiers in this article or CodeSmith, but we&amp;rsquo;ve now done enough to generate a DAL. Click the Run button in the CodeSmith toolbar to generate the code.&lt;/p&gt;
&lt;h2&gt;Step 4 &amp;ndash; Review the Generated Code&lt;/h2&gt;
&lt;p&gt;Open Visual Studio .NET and if you followed the directions above you should find a Demo.sln file in the c:\NetTiers\Northwind_Demo\ directory.&lt;/p&gt;
&lt;p&gt;Take a moment and browse the solution and project files in Visual Studio:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_7.png" width="317" height="248" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;You should find 3 projects within the solution:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Demo&lt;/b&gt; &amp;ndash; the main library that contains the classes you will use within your application to interact with the database. 
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Demo.DataAccessLayer&lt;/b&gt; &amp;ndash; the library containing the data access implementation code. 
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Demo.DataAccessLayer.SqlClient&lt;/b&gt; &amp;ndash; the library containing the Microsoft Patterns &amp;amp; Practices classes for working with the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Step 5 &amp;ndash; Compile &amp;hellip;and we&amp;rsquo;re done!&lt;/h2&gt;
&lt;p&gt;Next, with Visual Studio still open, compile the project.&lt;/p&gt;
&lt;p&gt;Congratulations! You now have a Data Access Layer that implements the recommended best practices from the Microsoft Patterns &amp;amp; Practices group for working with a database.&lt;/p&gt;
&lt;p&gt;You can now begin using your new Data Access Layer in other Visual Studio .NET projects. For example, below is code to retrieve, update and then delete an employee record.&lt;/p&gt;
&lt;pre&gt;using Demo.DataAccessLayer.SqlClient;&lt;br /&gt;&lt;br /&gt;// Select by primary key&lt;br /&gt;Employee employee = SqlDataRepository.EmployeeProvider.GetByEmployeeID(13);&lt;br /&gt;employee.FirstName = &amp;quot;John&amp;quot;;&lt;br /&gt;employee.LastName = &amp;quot;Doe&amp;quot;;&lt;br /&gt;&lt;br /&gt;// Save changes&lt;br /&gt;SqlDataRepository.EmployeeProvider.Save(employee);&lt;br /&gt;&lt;br /&gt;// Delete record&lt;br /&gt;SqlDataRepository.EmployeeProvider.Delete(employee);&lt;br /&gt;    &lt;/pre&gt;
&lt;p&gt;For more information on how to use the generated DAL, take a look at the .netTiers wiki here:&lt;a href="http://nettiers.com/DocumentationPage.ashx"&gt;http://nettiers.com/DocumentationPage.ashx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Remember all of the Data Access Layer code was generated by templates, so later when you change your database structure you can simply rebuild the DAL again from the templates. Furthermore, you can even extend the templates with your own ideas, comments, naming conventions, patterns, and so on. &lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;The possibilities for CodeSmith templates are limited only by your own creativity. As I&amp;rsquo;ve demonstrated in this article, CodeSmith is an exceptionally powerful developer productivity tool. Coupled with the .netTiers templates you can write a best practices Data Access Layer for your application in a matter of minutes.&lt;/p&gt;
&lt;p&gt;You can also watch a video of this presentation here:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://community.codesmithtools.com/r.ashx?id=1"&gt;http://community.codesmithtools.com/r.ashx?id=1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;One of the fun features added into version 3.1 was a simple &amp;quot;value calculator&amp;quot;. The value calculator provides a conservative estimate of the time saved by using CodeSmith: &lt;/p&gt;
&lt;p&gt;&lt;img src="http://community.codesmithtools.com/images/CodeSmith-NetTiers/CS_3.png" width="502" height="316" alt="" /&gt; &lt;/p&gt;
&lt;p&gt;As shown in the screenshot above, using the .netTiers templates with CodeSmith generated 91,559 lines of code. Assuming a developer can write approximately 50 lines of code per-hour (had we written this manually) writing the code we generated would have taken 1,800 hours. Taking this a step further and assuming that a developer&amp;rsquo;s time is approximately $60/hour, CodeSmith and .netTiers together saved you &lt;span style="text-decoration:underline;"&gt;1,800&lt;/span&gt; hours of your life and &lt;span style="text-decoration:underline;"&gt;$109,000&lt;/span&gt; for your company!&lt;/p&gt;
&lt;p&gt;So get CodeSmith&amp;hellip; and then go ask for a raise.&lt;/p&gt;
&lt;h2&gt;CodeSmith and .netTiers Resources&lt;/h2&gt;
&lt;p&gt;If you have questions about CodeSmith, please be sure to visit the CodeSmith community portal at: &lt;a href="http://community.codesmithtools.com/"&gt;http://community.codesmithtools.com&lt;/a&gt;. The CodeSmith community portal is a great resource where people can share templates, ideas, and help each other.&lt;/p&gt;
&lt;p&gt;If you are interested in purchasing CodeSmith, please visit the CodeSmith website at &lt;a href="http://www.codesmithtools.com/"&gt;http://www.codesmithtools.com&lt;/a&gt;. There you will find the CodeSmith store where you can purchase license keys to unlock the 30-day trial version. If you have other questions, just email &lt;a href="mailto:sales@codesmithtools.com"&gt;sales@codesmithtools.com&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you have questions about the .netTiers templates, please visit the .netTiers forum at:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://community.codesmithtools.com/forums/16/ShowForum.aspx"&gt;http://community.codesmithtools.com/forums/16/ShowForum.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://community.codesmithtools.com/aggbug.aspx?PostID=9655" width="1" height="1"&gt;</description><category domain="http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/tags/-netTiers/default.aspx">.netTiers</category><category domain="http://community.codesmithtools.com/CodeSmith_Community/b/tutorials/archive/tags/CodeSmith/default.aspx">CodeSmith</category></item></channel></rss>