本文整理汇总了C#中Book.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Book.Save方法的具体用法?C# Book.Save怎么用?C# Book.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Book
的用法示例。
在下文中一共展示了Book.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Book book = new Book() { Id = 1, Title = "Book 1", Author = "Author 1" };
book.Save(book);
Console.Read();
}
示例2: CommitChanges
public DataObjectOperationResult CommitChanges(BookFormModel postedData)
{
Mapper.CreateMap<BookFormModel, Book>();
var book = new Book(Db);
Mapper.Map<BookFormModel, Book>(postedData, book);
var results = book.Save();
postedData.Id = book.Id;
return results;
}
示例3: TestSaveFromBelongsTo2
public void TestSaveFromBelongsTo2()
{
var c = new Category { Name = "test" };
var b1 = new Book { Name = "123" };
var b2 = new Book { Name = "456" };
var b3 = new Book { Name = "789" };
b1.CurCategory.Value = c;
b2.CurCategory.Value = c;
b3.CurCategory.Value = c;
b3.Save();
var c1 = Category.FindById(c.Id);
Assert.IsNotNull(c1);
Assert.AreEqual("test", c1.Name);
Assert.AreEqual(3, c1.Books.Count);
Assert.AreEqual("123", c1.Books[0].Name);
Assert.AreEqual("456", c1.Books[1].Name);
Assert.AreEqual("789", c1.Books[2].Name);
}
示例4: TestSaveFromBelongsTo1
public void TestSaveFromBelongsTo1()
{
var c = new Category { Name = "test" };
var b1 = new Book { Name = "123" };
var b2 = new Book { Name = "456" };
c.Books.Add(b1);
c.Books.Add(b2);
b2.Save();
var c1 = Category.FindById(c.Id);
Assert.IsNotNull(c1);
Assert.AreEqual("test", c1.Name);
Assert.AreEqual(2, c1.Books.Count);
Assert.AreEqual("123", c1.Books[0].Name);
Assert.AreEqual("456", c1.Books[1].Name);
}