Hi,
I've just switched to Castle.ActiveRecord 2.1.0 and I'm puzzled about a behaviour change.
I used to be able to update a child's parent-reference by calling Update on the parent and then refreshing the child.
Now that doesn't work anymore, am I missing something completely? Or was I doing it wrong from the beginning?
The code below used to pass but now doesn't.
If I put a SessionScope.Current.Flush() after the email.Update() it works, but I would like to understand why, plus there are sooo many places to change if I cannot do it in another way.
And btw, I'm switching from 0.0.1.3...
using (new SessionScope())
{
Email email = new Email();
email.Save();
Attachment a = new Attachment();
email.Attachments.Add(a);
email.Update();
a.Refresh();
//the important part
Assert.That(a.Email, Is.Not.Null);
}
The classes are:
[ActiveRecord("emails")]
public class Email : ActiveRecordBase<Email>
{
[HasMany(typeof(Attachment),
Cascade = ManyRelationCascadeEnum.AllDeleteOrphan,
Lazy = true)]
public IList Attachment { get; set; }
}
and
[ActiveRecord("attachments")]
public class Attachment : ActiveRecordBase<Attachment>
{
[BelongsTo("email")]
public virtual Email Email { get; set; }
}
Thank you for replying!