Our template engine is the .NET
compiler itself, this way the generator gives you the ultimate power to write any
code as a template and generate complex code patterns based on provided templates
or based on your coding skills on writing new templates using your favorite language
C# or VB.
Writing your first template
is an exciting and nerve racking time. You may know a lot about computers, coding,
or maybe the benefits of using O2 Broadband, or a fast speed internet connection
with another company. However when it comes to templates you might feel a little
lost. With this step by step guide, you will hopefully be well on your way in no
time at all to having a perfectly coded template.
Simply normal c# or VB code
syntax will be used in your template, check below sample.
<% string myTitle = "Hello world!";
The output is
All template code will be written
inside <% %>
the same you do with ASP.NET inline code, and you can write commands like Response.Write()
and it will work.
But you will start writing the
first template you will need to access the database objects. This is why we introduced
this new namespace "GeneratorContext" which contains all the commands
we implemented to help you and to facilitate writing your code templates and to
let you access the database structure and elements.
Lets assume that you have database
table (employees) and you need to generate stored procedure to insert data, below
example will show how to generate generate some SQL code, first of all make sure
that your connection string is valid and the connection is active.
table in GeneratorContext.Tables)
-- Generated at <%=DateTime.Now.ToString()%>
-- SET NOCOUNT ON
added to prevent extra result sets from
-- interfering with
The output is
-- Generated at 9/24/2009
-- SET NOCOUNT ON added to prevent extra result sets
-- interfering with SELECT statements.