Consider the following example:
e.g.: consider an user with a list of blogs:
var user = session.Load<User>(1);
user.OwnedBlogs.Add(new WebLog { Title = "My blog #1", Creator =
user });
session.Update(user);
session.Flush();
This code works but the user is actually loaded from the database (I guess
that's because a property of the user instance is accessed thus the proxy
loads the entity instance).
This other piece of code works just as expected:
var webLog = new WebLog { Title = "My blog #2", Creator = new
User { ID=1 } };
session.Save(webLog);
session.Flush();
... but in my domain model the User entity is an aggregate root for the
WebLog entity, so I would like to insert a new WebLog through the User
instance.
The relationship between User and WebLog (virtual public IList<WebLog>
OwnedBlogs { get; set; }) is mapped as a bag, with cascade="all" and
lazy="true" (lazy="extra" yields the same results)
Is there something conceptually wrong in the examples above? Is there
another way to accomplish what I want to do?
Thanks in advance
--
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.