コード例 #1
0
ファイル: DemoData.cs プロジェクト: hhariri/MetaBlogAPI
        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;
        }
コード例 #3
0
        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);
 }