My Code Generator Now Generates Repository Factory Data Access Layer Classes

My Code Generator Now Generates Repository Factory Data Access Layer Classes

by David Hayden ( Florida .NET Developer ), Filed: Code Generation

 

This wasn't a real stretch since my code generator already generates Data Access Guidance Package Data Access Layer Classes, but I added some Repository Factory Templates since I was already in there making Stored Procedure Wrapper Classes ( Code Generation - Stored Procedure Wrappers for Data Access Layer ).

This is not a small task, because there are a number of classes generated by the Repository Factory Guidance Package that I need to generate:

  • Business Entity Classes
  • Business Entity Factory Classes
  • Selection Command Factory Classes ( by Primary Key and ALL )
  • Insert Command Factory Class
  • Update Command Factory Class
  • Delete Command Factory Class
  • Repository Interface Classes
  • Repository Classes

Luckily most of those are the same in the Data Access Guidance Package.

I generate some additional classes in my templates that you won't find in the Repository Factory Guidance Package:

  • Enum Classes for better performance in getting fields from DataReader
  • Stored Procedure Wrapper Classes ( added it today )
  • All Classes to support Views ( Repository Factory does not currently support Views )

Since I already made my version of the Repository Factory Pluggable with a custom Enterprise Library Configuration Add-In ( Repository Factory With Pluggable Database Provider - 4 Hours Including Custom Tooling ) I think were done.

 

Generate Repository Factory Classes

 

You can create the same templates easily using one of the template based code generation tools ( CodeSmith, MyGeneration, etc.).

Don't do this if you don't have to, however. The guidance package is the easiest solution if it generates code exactly like you want it and/or you know the Guidance Automation Toolkit well enough to modify the templates, etc. In this case, I am using my own custom version of the Repository Assembly, already had templates built so it was easy to modify, and wanted support for stored procedures and views. The effort was minimal but the value is great.

 

Source: David Hayden ( Florida .NET Developer )

Filed: Code Generation

posted on Monday, September 03, 2007 5:15 PM

My Links

Post Categories

Article Categories

Archives

Loose-Leaf Tea