示例#1
0
        public static void SetupData(ISession session)
        {
            using (ITransaction transaction = session.BeginTransaction())
            {
                var user = new User() { Username = "******" };

                session.Save(user);

                for (int i = 0; i < 10; i++)
                {
                    var blog = new Blog() { Name = String.Format("Blog{0}", i), User = user };

                    var category1 = new Category() { Blog = blog, Description = "Description1", HtmlUrl = "htmlurl1", RssUrl = "rssurl1" };
                    var category2 = new Category() { Blog = blog, Description = "Description2", HtmlUrl = "htmlurl2", RssUrl = "rssurl2" };
                    var category3 = new Category() { Blog = blog, Description = "Description3", HtmlUrl = "htmlurl3", RssUrl = "rssurl3" };

                    blog.AddCategory(category1);
                    blog.AddCategory(category2);
                    blog.AddCategory(category3);

                    session.Save(blog);

                    for (int j = 0; j < 1000; j++)
                    {
                        var post = new Post() { Date = DateTime.Now, Title = String.Format("Blog{0}Post{1}", i, j) };

                        post.Blog = blog;
                        session.Save(post);
                    }
                }
                transaction.Commit();

            }
        }
        public override void SetupData()
        {
            post1_title = "First Post";

            var post1 = new Post { Title = post1_title };
            var post2 = new Post {Title = "A second post"};

            Session.Save(post1);
            Session.Save(post2);

            post1_id = post1.Id;
        }
        public override void SetupData()
        {
            var user = new User() {Username = "******"};

            Session.Save(user);

            for (int i = 0; i < 10; i++)
            {
                var blog = new Blog() {Name = String.Format("Blog{0}", i), User = user};

                Session.Save(blog);

                for (int j = 0; j < 1000; j++)
                {
                    var post = new Post() { Date = DateTime.Now, Title = String.Format("Blog{0}Post{1}", i, j) };

                    post.Blog = blog;
                    Session.Save(post);
                }
            }
        }
示例#4
0
 public virtual bool Equals(Post other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Title, Title);
 }
示例#5
0
 public virtual void RemovePost(Post post)
 {
     _posts.Remove(post);
 }
示例#6
0
 public virtual void AddPost(Post post)
 {
     _posts.Add(post);
 }