예제 #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();

            }
        }
예제 #2
0
        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
파일: Post.cs 프로젝트: hhariri/MetaBlogAPI
 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
파일: Blog.cs 프로젝트: hhariri/MetaBlogAPI
 public virtual void RemovePost(Post post)
 {
     _posts.Remove(post);
 }
예제 #6
0
파일: Blog.cs 프로젝트: hhariri/MetaBlogAPI
 public virtual void AddPost(Post post)
 {
     _posts.Add(post);
 }