首先是映射,
<set name="Comments" table="cm_events_venue_comment" inverse="true"
lazy="true" generic="true" cascade="all-delete-orphan"
batch-size="10" order-by="dateCreated ASC">
<cache usage="read-write" />
<key column="venueId" />
<one-to-many class="VenueComment" />
</set>
Run Code Online (Sandbox Code Playgroud)
一次通过考试,
[Test]
public void CanSaveAndDeleteComments()
{
User u = TestDataHelper.CreateUser("Sir", "Talkalot");
VenueComment comment;
Venue v = GetVenueById();
PerformInTransaction(() =>
{
userRepository.SaveOrUpdate(u);
comment = new VenueComment()
{
Commenter = u,
Text = "I like ifs and buts and i cannot lie..",
DateCreated = DateTime.Now
};
v.AddComment(comment);
comment = new VenueComment()
{
Commenter = u,
Text = "And words ending in …Run Code Online (Sandbox Code Playgroud)