Class helper?


Now I have several classes and have an exported unit with Entities.
But what about any class functions and procedures?

For example, I have TAcc class and I need to add methods
and many others in the future, but it is not part of database structure,
it is program code but to add this method I should add it using exporting script.

Maybe add Class Helpers to a different unit?
What can You recommend?

I believe the only automated option would be using the customization script and adding those methods through it. If it's lot a code it can become cumbersome indeed. Or let the customization script add {$I} directives to include files and then you add code in those files. Or you use the customization script to add some macros and then you do some post processing in the file and replace those macros.

Unfortunately Delphi doesn't have a concept like partial classes from C# so it's hard to extend classes from another unit.
Class helpers are a possibility, yes, if all you need are methods and you do not need to add fields in the class, then it might work for you.


What if we create an "extended" class in which we "inject" the entity in a separate unit to prevent overwriting by the Data Modeler (e.g. TEntity_Extended.Create(TEntity) and then use a custom ObjectFactory to spawn TEntity_Extended objects instead of TEntity objects?

Could this be a feasible solution? If so, I'll give it a try with a small test app.

Thanks and regards,

Hi Mark, I don't thinks that's a good solution since TEntity_Extended will have to have all properties of TEntity, and include all attribute mappings. You can't delegate mapping of Aurelius entities to other classes or subclasses.