Custom field/property on Derived Model Objects

Posts   
 
    
mprothme avatar
mprothme
User
Posts: 78
Joined: 05-Oct-2017
# Posted on: 07-Apr-2021 17:51:24   
  • Build Version: 5.5 (5.5.1) RTM
  • Build Date: 17-Jan-2019
  • Project: Adapter project targetting .NET 4.5.2
  • Database: MS SQL 2016

We have several derived elements (DTO Class Models) in our project. There are a few that we'd like to add additional fields to that aren't directly tied to columns or relationships in their underlying tables.

Is there a way to add this using the designer? And if not is there a suggested best practice here?

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Apr-2021 04:58:36   

You need to create a partial class file, to be preserved across code generations. And if the custom property is common among all your DTO classes, then you can create a base class to have the extra property(s), and go to** Project->Settings->Derived Mode**l, select your derived model, click on DTO Class Model, and use the setting Root Derived Element base class name. Then all your DTOs will be extending that base class that you should write with your custom stuff.

mprothme avatar
mprothme
User
Posts: 78
Joined: 05-Oct-2017
# Posted on: 08-Apr-2021 19:34:26   

Awesome thanks!