Improved CodeSmith Templates for ORMapper

The following is news from Paul Welter, who's been gracious enough to create and update CodeSmith templates for my ORMapper:

I've updated the tempates on the CodeSmith site above. This update contains many new features. The biggest new feature is merge support. Now you can author new code in the generated entity class file and not loose your changes when the templates are re-run. The merge works by updating marked regions in the file. All your modifications will be saved as long as you don't edit regions marked as 'do not modify'. Another improvement is that it now generates a DataManager class that contains a singleton instance of the ObjectSpace class. Having this common singleton allows for generation of some default methods for each entity like Retrieve, RetrieveAll, Save and Delete. The goal of these updated templates was to abstract the ORMapper from the UI layer by creating methods off the entity objects. This leads to more of a true object oriented design. No longer does a consumer of the entity objects have to know any ORMapper syntax. Working with the entity now looks like ...

Customer cust = new Customer();
cust.FirstName = "Paul";
cust.LastName = "Wilson";
cust.Save();

All the ORMapper tracking and persisting is handled internal to the customer class. This is a much more intuitive syntax to work with.

There is also a new set of templates to generate NUnit test classes for each entity class. The test classes are very basic and designed as only a starting point. Another advantage of the improved way of working with the entity classes is that it is much easier to author tests for.

The templates should be used in the following order ...

1)MappingFile.cst - This generates the mapping file for the WilsonORMapper.
2)ClassGenerator.cst - This generates or updates the entity classes defined in the mapping file. This template also generates a DataManager class if it doesn’t already exist.
3)TestGenerator.cst - This generates NUnit test classes for each enity class. This is an optional template to use.

Thanks
Paul Welter

3 Comments

Comments have been disabled for this content.