I haven't looked at the templates yet, but if you are new to O/R Mapping this may be the way to learn: 3-Tiers Application Templates for CodeSmith
Maybe in future posts I will dig into those templates and discuss them further. Here is the description on the website:
"3-Tiers Application" are CodeSmith templates for object-relational mapping. It takes an existing SQLServer database and automatically generates a personnalized application block to use in your own .Net applications: winform, console or ASP.NET.
This application block features are:
- Generate the business objects (called entities), with a 1:1 mapping ( an entity for each table, with a property for each column).
- They are Serializable
- They trigger events
- They implements an IEntity interface, which contains the columns that are present in every table
- Generate Repositories classes for Database operations :
- Support for basic CRUD: UPDATE, DELETE, INSERT, SELECT ALL, PAGED SELECT, FIND
- Support for queries using primary key
- Support for queries using foreign key
- Support for queries using keys that are part of an index
- Support for queries using keys that are part of a junction table
- Generate strongly-typed collections for entities and repositories.
- Implement CollectionBase , IBindingList, IList and ICloneable
- Sortable
- bindable to datagrid, or any winform or asp.net controls
- it creates webservices for distributed programming
- create the stored procedures script
- generate configurable Visual Studio projects/solution
- a full set of unit tests.
- Each object has a concrete and a base class which it inherit from. The concrete class is generated just once, so you have can use it to add you custom code
- the code is fully commented (it use to Description metadata of the database) and follow the microsoft naming guidelines
- Open source !!! You can modify the templates and contribute (http://www.sourceforge.net/projects/cstemplates)
Check it out.