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

Published Saturday, January 29, 2005 12:47 PM by PaulWilson

Comments

# re: Improved CodeSmith Templates for ORMapper

My only complaint is that it does not map Views. I'm not sure what it is going to take to add that ability, but I'm working on it.

Monday, January 31, 2005 10:56 AM by Dustin B

# re: Improved CodeSmith Templates for ORMapper

Looks like its MySql compatible as well; great update!

Tuesday, February 01, 2005 11:23 PM by David Dimmer

# re: Improved CodeSmith Templates for ORMapper

[UPDATE]
He made an update so views can be mapped and generated.

Wednesday, February 02, 2005 8:53 AM by Nidifice

# re: Improved CodeSmith Templates for ORMapper

First, I'd like to state nice update... There are a couple of tweaks id like to see...

First it would be very helpful, if the tables in the mapping.config were made in alphabetical order... if you have lots of tables it is hard to find the one your looking for...

Second, on the entity update, I was already doing something similar... I created a base class (ORMappedObject is what I called it) which I inherited which had most of this functionality... As almost all of these new methods are not typed, or can be typed generically that is; and this mod seems to generate alot of redundant code... Any chance we could see something like this worked into the template?

Dan

Monday, February 07, 2005 6:14 PM by Dan Bartels

# re: Improved CodeSmith Templates for ORMapper

I recommend that you make any comments in the thread at CodeSmith since I'm not really working on the these templates myself -- although I think they are great. I also think the point of the CodeSmith templates is of course a sample set of templates, since unlike my ORHelper you can alter the templates yourself.

Thanks, Paul Wilson

Monday, February 07, 2005 6:31 PM by Paul Wilson

Leave a Comment

(required) 
(required) 
(optional)
(required)