Book a Demo

Author Topic: Instantiating association properties  (Read 4041 times)

kodo65

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Instantiating association properties
« on: May 12, 2011, 10:13:03 pm »
Hi!

I have a two classes let's call them parent and child. There's a one-to-many relationship between them. Now I have a public property of the parent, child, which denotes that it is of type Dictionary<int, child> (C#) but the declaration fails to include ' = new Dictionary<int, child>'. There must be a possibility to override the property declarations for these kind of associations so the property gets instantiated but I haven't found it.

Embarassing:-)

I'd appreciate if anybody could point me in the right direction...

Thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Instantiating association properties
« Reply #1 on: May 13, 2011, 04:55:18 pm »
Have you tried the "Initial Value" field?

Geert

kodo65

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Instantiating association properties
« Reply #2 on: May 16, 2011, 04:11:40 pm »
Hi Geert!

I've tried the following:

On the association, source side ("many side"), I've added a qualifier of type "Child" with an initial value of "new Dictionary<int, child>". When generating code nothing happens - the same "public Dictionary<int,  child> children;" shows up...

I'm not sure if this was what you wanted me to try?

Cheers

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Instantiating association properties
« Reply #3 on: May 16, 2011, 04:30:46 pm »
I was thinking about the initial value of an attribute.

Geert

kodo65

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: Instantiating association properties
« Reply #4 on: May 16, 2011, 06:36:15 pm »
Good suggestion. Thanks!