本文整理汇总了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();
}
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}