Customizing Navigator/Relationship Names

Posts   
 
    
mprothme avatar
mprothme
User
Posts: 78
Joined: 05-Oct-2017
# Posted on: 03-May-2022 19:00:39   

Build Version: 5.5 (5.5.0) RTM, Build Date: 02-Nov-2018 Project: Adapter project targeting .NET 4.5.2 Database: MS SQL on 2016

When reverse engineering entities from table definitions is there a way to have custom logic run when deriving the name that a relationship/navigator should have in the generated code? We have a few specific naming conventions when generating relationships that today we maintain by hand, mainly because some of them are table-specific and are derived from parts of the column name.

Alternatively, is there any way to load the project file into whatever class you use to model it within the application, run some logic on the generated relationships (potentially updating their names), and then save it again?

Our big goal here is to be able to fully run the code generation process from the CLI (refresh from the database, create entity definitions, generate code, etc) but the way we name our relationships today gets in the way of that. I think we could load the project file in XML and work with it that way, but I'd really like to not do that if its possible simple_smile

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 03-May-2022 20:56:14   

mprothme wrote:

Build Version: 5.5 (5.5.0) RTM, Build Date: 02-Nov-2018 Project: Adapter project targeting .NET 4.5.2 Database: MS SQL on 2016

When reverse engineering entities from table definitions is there a way to have custom logic run when deriving the name that a relationship/navigator should have in the generated code? We have a few specific naming conventions when generating relationships that today we maintain by hand, mainly because some of them are table-specific and are derived from parts of the column name.

Have you looked at the patterns in the project settings -> Entity model -> Element Name Construction ?

Additionally, you can create a plugin and auto-bind it to a designer event. https://www.llblgen.com/Documentation/5.9/Designer/Functionality%20Reference/DesignerEventPluginBinder.htm

There's not a designer event for your specific task, but you could e.g. run it after project load and verify things, or run it after validation.

Alternatively, is there any way to load the project file into whatever class you use to model it within the application, run some logic on the generated relationships (potentially updating their names), and then save it again?

Yes you can do that, please see the sourcecode of the CLIGenerator/refresher, which is in the sourcecode archive. These tools setup the environment and then load a project and after that you can do with the object model what you want, and e.g. save it again too, that's just a method call.

Frans Bouma | Lead developer LLBLGen Pro
mprothme avatar
mprothme
User
Posts: 78
Joined: 05-Oct-2017
# Posted on: 06-May-2022 23:04:41   

Awesome thank you!!!