alexdresko wrote:
Can someone please explain what these "controller" templates are used for?
They generate a bunch of helper "Manager" classes which provider methods for doing usual tasks like Fetching, Saving and Deleting.
So instead of writing:
PersonEntity entity = new PersonEntity(personID);
using (DataAccessAdapter adapter = new DataAccessAdapter()){
adapter.Fetch(entity);
}
You simply have to call:
PersonEntity entity = PersonManager.Fetch(PersonID);
It gets more helpful when you are think about related objects for example:
PrefetchPath2 prefetch = new PrefetchPath2( (int)EntityType.PersonEntity );
prefetch.Add( PersonEntity.PrefetchPathHomeAddress );
PersonEntity entity = new PersonEntity(personID);
using (DataAccessAdapter adapter = new DataAccessAdapter()){
adapter.Fetch(entity, prefetch);
}
is replaced by:
PersonEntity entity = PersonManager.FetchWithHomeAddress(PersonID);
Something that is missing in these templates however is the ability to pass in an existing DataAccessAdapter... which would be required for transaction control.
The nice thing, is that its easily added by simply adding a contructor which takes DataAccessAdapter as a parameter and stores in a field which is accessed by the DataAdapter property of the ManageBase class.
[UPDATE]
This is of course "rubbish" as the methods are static.
You will have to provide overloaded methods which take a DataAccessAdapter instance as a parameter...
[/UPDATE]
Marcus