當前位置: 首頁>>代碼示例>>C#>>正文


C# Blog.Create方法代碼示例

本文整理匯總了C#中Blog.Create方法的典型用法代碼示例。如果您正苦於以下問題:C# Blog.Create方法的具體用法?C# Blog.Create怎麽用?C# Blog.Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Blog的用法示例。


在下文中一共展示了Blog.Create方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FillData

		public void FillData()
		{
			ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Blog), typeof(Post));
			Recreate();

			for (int i = 1; i <= 10; i++)
			{
				var blog = new Blog(i) { Name = "n" + i };
				blog.Create();
			}
		}
開發者ID:sheefa,項目名稱:Castle.ActiveRecord,代碼行數:11,代碼來源:ActiveRecordDetachedQueryGenericTestCase.cs

示例2: SimpleOperations3

        public void SimpleOperations3()
        {
            using (new SessionScope()) {

                var blogs = Blog.FindAll().ToArray();

                Assert.IsNotNull(blogs);
                Assert.AreEqual(10, blogs.Length);

                var blog = new Blog {Name = "hammett's blog", Author = "hamilton verissimo"};
                blog.Create();

                blogs = Blog.FindAll().ToArray();
                Assert.AreEqual(blog.Name, blogs[10].Name);
                Assert.AreEqual(blog.Author, blogs[10].Author);

                Assert.IsNotNull(blogs);
                Assert.AreEqual(11, blogs.Length);

                blog.Name = "something else1";
                blog.Author = "something else2";
                blog.Update();

                blogs = Blog.FindAll().ToArray();

                Assert.IsNotNull(blogs);
                Assert.AreEqual(11, blogs.Length);
                blog = blogs.Last();
                Assert.AreEqual(blog.Name, blog.Name);
                Assert.AreEqual(blog.Author, blog.Author);
            }
        }
開發者ID:shosca,項目名稱:ActiveRecord,代碼行數:32,代碼來源:ActiveRecordTestCase.cs

示例3: SetUp

        public override void SetUp()
        {
            base.SetUp();

            using (new SessionScope()) {
                for (var i = 1; i <= 10; i++) {
                    var blog = new Blog(i) {Name = "n" + i};
                    blog.Create();
                }
            }
        }
開發者ID:shosca,項目名稱:ActiveRecord,代碼行數:11,代碼來源:ActiveRecordTestCase.cs

示例4: LinqSimpleOperations2

        public void LinqSimpleOperations2()
        {
            using (new SessionScope()) {
                var blogs = Blog.All;
                Assert.IsNotNull(blogs);
                Assert.AreEqual(10, blogs.Count());

                var blog = new Blog {Name = "hammett's blog", Author = "hamilton verissimo"};
                blog.Create();

                Assert.AreEqual(11, (from b in Blog.All select b).Count());

                blogs = Blog.All.OrderByDescending(b => b.Id);
                Assert.AreEqual(blog.Name, blogs.First().Name);
                Assert.AreEqual(blog.Author, blogs.First().Author);

                blog.Name = "something else1";
                blog.Author = "something else2";
                blog.Update();

                blogs = Blog.All.OrderByDescending(b => b.Id);
                Assert.IsNotNull(blogs);
                Assert.AreEqual(11, Blog.All.Count());
                Assert.AreEqual(blog.Name, blogs.First().Name);
                Assert.AreEqual(blog.Author, blogs.First().Author);
            }
        }
開發者ID:shosca,項目名稱:ActiveRecord,代碼行數:27,代碼來源:ActiveRecordTestCase.cs

示例5: SimpleOperations2

        public void SimpleOperations2()
        {
            ActiveRecordStarter.Initialize(GetConfigSource(), typeof(Post), typeof(Blog));

            using (new SessionScope())
            {
                Recreate();

                Post.DeleteAll();
                Blog.DeleteAll();

                var blogs = Blog.Queryable;
                Assert.IsNotNull(blogs);
                Assert.AreEqual(0, blogs.Count());

                Blog blog = new Blog();
                blog.Name = "hammett's blog";
                blog.Author = "hamilton verissimo";
                blog.Create();

                Assert.AreEqual(1, (from b in Blog.Queryable select b).Count());

                blogs = Blog.Queryable;
                Assert.AreEqual(blog.Name, blogs.First().Name);
                Assert.AreEqual(blog.Author, blogs.First().Author);

                blog.Name = "something else1";
                blog.Author = "something else2";
                blog.Update();

                blogs = Blog.Queryable;
                Assert.IsNotNull(blogs);
                Assert.AreEqual(1, Blog.Queryable.Count());
                Assert.AreEqual(blog.Name, blogs.First().Name);
                Assert.AreEqual(blog.Author, blogs.First().Author);
            }
        }
開發者ID:stasizb,項目名稱:ActiveRecord,代碼行數:37,代碼來源:ActiveRecordLinqTestCase.cs

示例6: SimpleOperations2

        public void SimpleOperations2()
        {
            Blog[] blogs = Blog.FindAll();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(0, blogs.Length);

            Blog blog = new Blog();
            blog.Name = "hammett's blog";
            blog.Author = "hamilton verissimo";
            blog.Create();

            blogs = Blog.FindAll();
            Assert.AreEqual(blog.Name, blogs[0].Name);
            Assert.AreEqual(blog.Author, blogs[0].Author);

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Length);

            blog.Name = "something else1";
            blog.Author = "something else2";
            blog.Update();

            blogs = Blog.FindAll();

            Assert.IsNotNull(blogs);
            Assert.AreEqual(1, blogs.Length);
            Assert.AreEqual(blog.Name, blogs[0].Name);
            Assert.AreEqual(blog.Author, blogs[0].Author);
        }
開發者ID:zhoufoxcn,項目名稱:ActiveRecord,代碼行數:30,代碼來源:ActiveRecordGenericsTestCase.cs


注:本文中的Blog.Create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。