Changing the Data Access Repository Class Template

Topics: General Discussion Forum, July and December Releases Forum, Service Factory Modeling Edition Forum
Jun 6, 2007 at 11:29 AM
Hi,

I want to use caching in my data access classes which are created by WSSF by adding a variable to hold the collection of business entities in each repository class.

Is it possible to change the template used to create the Data Access classes, specially the repository one? If yes, how?

Many Thanks
Jun 6, 2007 at 1:24 PM
You can update the text templates that handles the code generation. For this scenario you may update the
".t4" files in the Data Access Guidance Package located under "templates\T4" subfolder and take a look at the "\BE\BusinessEntity.t4" file where you may add your custom logic to your generated entities.
Jun 7, 2007 at 11:25 AM
I found it :)

For creating stored procedures for SQL Server 2000, I can just change one of those templates as well, great

Thanks Charly
Aug 28, 2007 at 1:17 PM
Wouldn't it be easier if it was adjusted in the Generic Repository class? That way you can hook up the CacheManager in every method like Find, FindOne, Add, Remove and Update...

But then again .. is it even usefull to implement caching in the repository class? Wouldn't it get cleared every single time you make a new repository? (and yes, that's every single time :s or can we have some sort of global repository for every business entity?). The only solution to me is to store your cache in a database. But then it would only be usefull to complex objects that have childclasses. And it would have to load the cache every time you make a new repository.... so I'm starting to wonder if this isn't too much overhead :s

Please some insight to this stuff since it has been driving me slightly insane for the past few hours :)