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
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);
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]