I need to suppress the xxxxId field for some properties

Posts   
 
    
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 10-Jul-2017 16:25:43   

I have a class [User] which owns a single [Address] via a property named AddressId.

This is an aggregate root scenario where the [Address] will exist as part of the [User] - so I never want the AddressId property generated, only the Address : Address property.

Is there a way I can mark a property to behave in this way? If not, is there a way I can add metadata to my model (via tagged-value or something) so I can alter the code-gen to deal with this?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Jul-2017 20:59:55   

The field is needed to maintain the relation. For the system to find out which Addresses belongs to which users at the model side, the field needs to be there.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 11-Jul-2017 12:15:42   

You can mark it as 'internal' though. It's a setting for a field on the 'Code generation info' tab of the entity editor.

By default a field is 'public' (which is driven by the default setting in the project settings -> Entity Model -> LLBLGen Pro Runtime Framework). You can mark the field as 'internal' by selecting the field on teh code generation info tab and then setting the 'Field property is public' setting to false.

This gets tedious for a lot of fields, so you can do that in one go for multiple fields/elements by using the 'bulk element setting manipulator' dialog, using Tools-> Bulk element setting manipulator.

then select as element type at the top right 'normal field' and scroll the grid so you'll see the last column, 'Is foreign key'. Sort that column so you have all FK fields together, select all these rows in the grid and change the setting in the property grid below it.

Click OK.

Frans Bouma | Lead developer LLBLGen Pro
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 11-Jul-2017 12:18:18   

Walaa wrote:

The field is needed to maintain the relation. For the system to find out which Addresses belongs to which users at the model side, the field needs to be there.

I don't think you are correct. EF will persist an Address object when the parent has a property of type Address and no AddressId property to go with it.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 11-Jul-2017 13:35:28   

mrpmorris wrote:

Walaa wrote:

The field is needed to maintain the relation. For the system to find out which Addresses belongs to which users at the model side, the field needs to be there.

I don't think you are correct. EF will persist an Address object when the parent has a property of type Address and no AddressId property to go with it.

That's EF, we were assuming you used our own runtime framework (which is different from EF)

If you use EF (please confirm) then you can simply hide the foreign keys in the project settings -> Entity Model -> Entity Framework

Frans Bouma | Lead developer LLBLGen Pro