Hi all,
I'm new to ActiveRecord. When playing around with one-to-one
associations I stumbled upon the following problem:
I'm trying to model a one-to-one relationship (user-userprofile in
this case). I already learned that this may not be a best practice,
but let's ignore that for a moment (I'm still trying to understand
what's going on).
[ActiveRecord]
public class TestUser : ActiveRecordBase<TestUser>
{
[PrimaryKey(PrimaryKeyType.GuidComb)]
public Guid Id { get; set; }
[OneToOne(Cascade = CascadeEnum.All, Fetch = FetchEnum.Join)]
public TestUserProfile Profile { get; set; }
}
[ActiveRecord]
public class TestUserProfile : ActiveRecordBase<TestUserProfile>
{
[PrimaryKey(PrimaryKeyType.GuidComb)]
public Guid Id { get; set; }
}
I would expect the following code to save a user with profile,
yielding the same Id in the database:
[Test]
public void save_user_saves_profile()
{
var user = new TestUser
{
Profile = new TestUserProfile()
};
user.Save();
}
The actual result however is that both objects are saved with a
different key. Am I missing something??
--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=.