NHibernate Templates for Smart Code Generator
To learn more about Smart Code please read the next article, by clicking here.
The sample code and templates, are based in the next article NHibernate Best Practices with ASP.NET . In this excellent article, Billy McCafferty, describes best practices for leveraging the benefits of NHibernate 1.2, ASP.NET.
For this article we’ll try to be original…..and we’ll use the Northwind database as sample, but these examples will work with any database
Code Generation, a brief overview
The Smart Code tool makes possible the automatic generation of programs and components that interact with database systems. It works by reading a database schema, allowing the user to set certain extended properties for tables and columns, and applying templates to each table in order to generate code. The templates are themselves programs that access the Smart Code Object Model to produce tailored programs and components. Although Smart Code comes with a set of basic templates, users may edit these or create their own to suit their particular project needs. Moreover, templates may be written in C# or VB.NET (or theoretically in any .NET language that supports the creation of dynamic-link libraries).
Quick Start Guide
Smart Code is a very powerful tool, and perhaps the best way to learn how to use it is to see a sample application running and then go back and examine which features of Smart Code were responsible for the application’s functionality.
- On the web.config and modify the connection.connection_string value
- Play with the application, open up different pages and entering some data.
- Open the Newin.scp project with the last release of Smart Code.
- Compile the NHibernateTemplates and WebTemplates and Load the dlls into Smart Code.
- Change some properties in Newin.scp project, this will show you the effect of different attribute settings and template assignments.
Technorati Tags: Nhibernate