Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

How can I add comments to my templates?

A. Template comments can be added using the <%- -%>tokens.Q.

How can I create a property that has

...

a drop-down of values to choose from?

A. Use a script block to define an enumerated property.Q.

How can I prevent ASP.NET tags from confusing my templates?

A. Properly escape the them using ASP.NET tags.Q.

How can I declare a constant in my template?

A. Constants must be declared inside <script runat="template"> tags.

Code Block
languagevbcsharp
<script runat="template">
private const string MY_CONST = "example";
</script>

...

How can I debug my templates?

A. You can compile your templates in debug mode and set breakpoints in them.Q.

How can I add a property that lets me select a folder?

A. Decorate the property with the FolderNameEditor attribute.Q.

How can I use sub-templates?

A. CodeSmith Generator includes a full API to let you make use of sub-templates.Q.

What assemblies and namespaces are loaded by default into a template?

A. Assemblies: mscorlib, System, Assemblies:

  • System
  • System.Core
  • System.Xml

...

  • System.Data

...

  • System.Drawing

...

  • System.Design
  • Microsoft.VisualBasic

...

  • System.Windows.Forms

...

  • CodeSmith.Engine
  • CodeSmith.Core

Namespaces:

  • System

...

  • System.Data

...

  • System.Diagnostics

...

  • System.ComponentModel

...

  • Microsoft.VisualBasic

...

  • CodeSmith.Engine

...

Is it possible to determine whether a column is an identity column using SchemaExplorer?

A. Yes. Use , use the CS_IsIdentity property.Q.

Is it possible to determine a column's default value using SchemaExplorer?

A. Yes. Use , use the CS_Default property.

Code Block
languagecsharp
    <%
    foreach(ColumnSchema cs in SourceTable.Columns)
    {
        if (cs.ExtendedProperties["CS_Default"] != null)
        {
            Response.WriteLine(cs.ExtendedProperties["CS_Default"].Value);
        }
    }
    %>

...

How can I enumerate the input and output parameters of a stored procedure using SchemaExplorer?

A. The CommandSchema object contains both input and output parameter collections which can be used to read these parameters.Q.

What if my template contains non-ASCII characters?

A. You can use the ResponseEncoding attribute of the CodeTemplate directive to set the encoding for the template.