ListCollection & insertion at specified position

Hi,
this time I’m trying to manage a sorted list collection.
I’ve two class A and B, bound with a one-to-many relation (A 1->* B)
I need that B is a sorted list, so I chose to use List as Collection Type.
I try to insert an B element to a specified position (between other elements) but it seems don’t work fine.

I used follow code:

  
......
                A a = AFactory.LoadAByORMID(1);
                B b1 = BFactory.CreateB();
                b1.Testo = "Nuovo 2";
                b1.A = a;
                a.bs.Insert(1,b1);
                a.Save();
                tx.Commit();

....
 

Where object a already contains 4 elements…
What’s wrong?
sortedList.vpp

Hello maurizio316,

Thank you for your post. I will ask our engineers about this and get back to you.

Best regards,
Jick

Hi maurizio316,

The following shouldn’t be called. Calling this will automatically append b1 to the collection:
b1.A = a;

If the above statement is called, this statement will add the b1 to a again.
a.bs.Insert(1,b1);

Best regards,
Jick

Hi Jick,
thanks for your fast answer…
Now, the question is:
I’ve an A object with its collection of three existent elements (B). How can I insert a B object at second position?

P.S.: I’m developing in C#

[quote=Jick]Hi maurizio316,

The following shouldn’t be called. Calling this will automatically append b1 to the collection:
b1.A = a;

If the above statement is called, this statement will add the b1 to a again.
a.bs.Insert(1,b1);

Best regards,
Jick[/quote]

Please try:

A a = AFactory.LoadAByORMID(1);
B b1 = BFactory.CreateB();
b1.Testo = “Nuovo 2”;
a.bs.Insert(1,b1);
a.Save();
tx.Commit();

I’m sorry, I forgot to tell you: I’ve already tried this code, obtaining following exception:
not-null property references a null or transient value: test.B.ORM_A

[quote=Jick]Please try:

A a = AFactory.LoadAByORMID(1);
B b1 = BFactory.CreateB();
b1.Testo = “Nuovo 2”;
a.bs.Insert(1,b1);
a.Save();
tx.Commit();[/quote]

Hi maurizio316,

We have fixed this problem. I will prepare a patch and notify you afterwards.

Best regards,
Jick

Hi maurizio316,

The problem is fixed. Please download the patch at:
http://202.126.208.239/6-0-2_sp2_20070712a/VP_Suite_Windows_3_0_sp2_20070712a.exe

Please install by overwriting the current installation. Feel free to let me know if there are any questions.

Best regards,
Jick

Sorry Jick,
Is it hard for you prepare a patch for linux too?

You’re always very fast, thx
Maurizio

[quote=Jick]Hi maurizio316,

The problem is fixed. Please download the patch at:
http://202.126.208.239/6-0-2_sp2_20070712a/VP_Suite_Windows_3_0_sp2_20070712a.exe

Please install by overwriting the current installation. Feel free to let me know if there are any questions.

Best regards,
Jick[/quote]

Hi maurizio316,

No problem. Please download at:
http://files3.visual-paradigm.com/200707/Patch/sp2_20070712e/VP_Suite_Linux_3_0_sp2_20070712e.sh

Best regards,
Jick