Related record referencing

Posts   
 
    
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 30-Jul-2010 09:20:29   

Hi,

I'm migrating from 2.6 to 3.0. When you have to tables A en B that have a 1:n relation, with the code generated bij 2.6 one could use the following:

AEntity z = new AEntity(123).

if (z.B.Count > 0) .....

I.e. the reference to the related entities uses the singular name of B.

When I generate the code under 3.0 accessing B using the singular name is not possible. You have to code

if (z.Bs.Count > 0) .....

Is this the new standard naming convention? Can it be changed, e.g. in the project propertie?

Best regards,

Jan

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Jul-2010 09:40:43   

Please check this doumentation link: How to disable name singularization

But in your case you should pick "NameSingularToPluralConversion" Designer Event.

JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 30-Jul-2010 10:04:17   

In the default situation both plural to singular and singular to plural are active. Is this the standard LLBLGen promotes?

I like to stick to default settings as mucht as possible.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Jul-2010 10:11:55   

Yes these are the defaults.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 30-Jul-2010 16:00:01   

In v3.0, pluralization/singularization is on by default. In v2.6 you had to enable it.

Frans Bouma | Lead developer LLBLGen Pro
JayBee
User
Posts: 282
Joined: 28-Dec-2006
# Posted on: 30-Jul-2010 16:40:31   

As mentioned, I prefer working with default settings. Therefor I never changed anything in the settings except for removing prefixes.

I allways give my tables singular names. Using plural in references to related items is something I normally would not do. In accessing individual fields, you have to specify the index of the entry you want. I prefer entity.RelatedField(i) above entity.RelatedFields(i). However, my preference for using defaults overules this.disappointed

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 30-Jul-2010 17:55:55   

You can change the pluralization in references, by changing the patterns. Honestly, the defaults given are just examples in this case, you really should tweak them to make them fit how you want to work, they're there for that simple_smile

Frans Bouma | Lead developer LLBLGen Pro