public virtual void AddComment(Comment comment) { comments.Add(comment); comment.Blog = this; }
public void Populate() { var session=this.Session; using(var transaction = session.BeginTransaction()) { for (int i = 0; i < 100; i++) { var blog = new Blog{Body = "Body" + i, Title = "Title" + i}; for (int j = 0; j < 5; j++) { var comment = new Comment {Author = "Fredek" + j, Body = "Comment Body" + j, Blog = blog}; blog.AddComment(comment); } session.Save(blog); } transaction.Commit(); } session.Close(); }