Tod1d's CodeSmith Templates v 2.0

File Details
Downloads: 1122 File Size: 24kB
Posted By: Tod Birdsall Views: 3317
Date Added: Wed, Aug 29 2007

These are the template files I use to generate the stored procedures and classes that I use as the backbone of my C# ASP.NET and console applications. The generated code will provide you with your data access layer and business layer. Simply point the templates to a table in your database and your CRUD (Create, Read, Update and Delete) code will automatically be generated, along with the associated business entity and custom collection.

If you have any feedback, please contact me. I hope these templates help you as much as they have helped me.

Author: Tod Birdsall
Credits:
    The templates that I use are derived from the sample templates that are included with CodeSmith 2.6.

Requirements:
 - .NET 2.0
 - CodeSmith 2.6 (Freeware version available here: http://www.codesmithtools.com/freeware.aspx)
    - Requires .NET 1.1
 - Your database tables to use INT type as primary key.

Instructions:

 1. Create a project new class library project in Visual Studio 2005. I normally name mine with suffixed with "Lib" (e.g. MyAppLib).
 2. Add SQLHelper.cs, DataEntityBase.cs, DataEntityBaseList.cs, and ConfigurationUtil.cs to your project. You will find them in the \RequiredClasses\ directory included with this ZIP file.
 3. Create your stored procs using Tod1d_StoredProcedures.cst and add them to your database by copying and pasting the text into SQL Query Analyzer and running it.
 4. Create your classes using Tod1d_ClassLibrary.cst. The only required field is SourceTable.
 5. Drag the newly created classes into your class library project.

Release notes:

v 2.0

 - You no longer have to manually creat class (.cs) files. Files are now generated in an output directory. You can drag them into your solution.
 - You can make changes to the classes without having them overwritten when you regenerate the code. Simply copy and paste over the files in the "Generated" folder. Thanks to Pete Maroun for this suggestion.
 - All entity classes are serializable by default. Thanks to Matthew Hinton for this suggestion and for testing this version of the template files.
 - Fixed bug where you were required to close the template before generating another set of classes or stored procedures.

v 1.0

 - Instructions included with code that generates the classes.

 - Less copy and pasting.

 - Support for 'list' tables. An example of a 'list' table would be a table used to store data that fills a dropdown. (i.e. States). Tables where you want to return all records.

You can find version 1.0 of these templates here.

Filed under:
Comments
No comments exist for this file.

Add Comment

Name (required)
Web Site (optional)
Comment (required)
Add