Hi @swin,
I am a colleague of @KHV and I have developed something in the direction described in his post above.
Please, find attached inside Attachment.zip a modified template file “ComponentDataAccess.cst” and a modified generated source file “OrdersServiceBase.generated.cst”.
In order to detect easily my modifications, search in the attached files the comment
// PROTOTYPE CODE.
Explanation (let’s take the example of Orders from Nothwind database):
I have easily modified the existing template in order to send as parameter to the CRUD operations (Insert/Delete/Save/Update) the I<Entity> instead of <Entity> (IOrders instead of Orders).
The problems started inside the generated code where I have obtained compilation errors
in places where <Entity> (Orders) was explicitely required.
For example, database operations require <Entity> argument, not I<Entity>:
public IOrders Save(IOrders entity) { .........
/* Persist Entity */
dataProvider.OrdersProvider.Save(transactionManager, entity);
There the “entity” variable (of type I<Entity> = IOrders) needed to be casted to <Entity> (Orders):
/* Persist Entity */
dataProvider.OrdersProvider.Save(transactionManager, (Orders)entity);
Of course, casting to Orders solves only the compilation problems, but at runtime an exception may be thrown.
It means that, in order to produce consistent code, it is necessary to modify also the templates of the DataLayer and we go in a cascade of modifications.
I have stopped myself at this point, because I realize that my modifications are bigger than expected.
Please give me any advice if my direction of working is good or not.