本文整理汇总了C#中Interfaces.CommitChanges方法的典型用法代码示例。如果您正苦于以下问题:C# Interfaces.CommitChanges方法的具体用法?C# Interfaces.CommitChanges怎么用?C# Interfaces.CommitChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interfaces
的用法示例。
在下文中一共展示了Interfaces.CommitChanges方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateStatusOfOrders
//-------------------------------------------------------------------------------------------------------------------------------------------------
private static void UpdateStatusOfOrders(Interfaces.Repository1.IOnlineStoreRepository repo)
{
using ( repo )
{
var order1 = repo.Orders.Single(o => o.Id == 1);
order1.Status = Interfaces.Repository1.OrderStatus.ProductsShipped;
repo.Orders.Update(order1);
var order2 = repo.Orders.Single(o => o.Id == 2);
order2.Status = Interfaces.Repository1.OrderStatus.PaymentReceived;
repo.Orders.Update(order2);
repo.CommitChanges();
}
}
示例2: InsertOrder1
//-------------------------------------------------------------------------------------------------------------------------------------------------
private static void InsertOrder1(Interfaces.Repository1.IOnlineStoreRepository repo)
{
using ( repo )
{
var product1 = repo.Products.Single(p => p.Name == "ABC");
var product2 = repo.Products.Single(p => p.Name == "DEF");
var order = repo.Orders.New();
order.PlacedAt = new DateTime(2015, 1, 1, 12, 0, 0);
order.OrderLines.Add(repo.NewOrderLine(order, product1, quantity: 22));
order.OrderLines.Add(repo.NewOrderLine(order, product2, quantity: 11));
repo.Orders.Insert(order);
repo.CommitChanges();
}
}
示例3: InsertProducts
//-------------------------------------------------------------------------------------------------------------------------------------------------
private static void InsertProducts(Interfaces.Repository1.IOnlineStoreRepository repo)
{
using ( repo )
{
var product1 = repo.Products.New();
product1.Name = "ABC";
product1.Price = 123.45m;
var product2 = repo.Products.New();
product2.Name = "DEF";
product2.Price = 678.90m;
repo.Products.Insert(product1);
repo.Products.Insert(product2);
repo.CommitChanges();
}
}