本文整理汇总了C#中Db.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# Db.Commit方法的具体用法?C# Db.Commit怎么用?C# Db.Commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db.Commit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TomFooReadTests
public TomFooReadTests()
{
db = new Db("Db");
using (var cx = new SqlConnection(db.ConnectionString))
{
cx.Open();
cx.ExecuteAsync("truncate table dbo.Foo").Wait();
}
originals = Enumerable.Range(0, 500).Select(i => new Foo
{
Id = Guid.NewGuid(),
Int = i,
IntNull = i,
DateTime2 = DateTime.UtcNow,
DateTime2Null = DateTime.UtcNow,
DateTimeOffset = DateTimeOffset.Now,
DateTimeOffsetNull = DateTimeOffset.Now,
Bit = true,
BitNull = true,
Float = 1,
FloatNull = 1,
Decimal = 1,
DecimalNull = 1,
Guid = Guid.NewGuid(),
GuidNull = Guid.NewGuid(),
Nvarchar = "Created",
Varbinary = new byte[] { 0, 1, 2, 3 },
Fi = new Fi { Name = "I'm a fi you're a foo.", Number = 1 },
Fees = new[]
{
new Fee { Name = "I'm a fee you're a foo.", Number = 2 },
new Fee { Name = "I'm another fee you're a foo.", Number = 3 }
},
}).OrderBy(o => o.Id).ToList();
db.Foos.AddRangeAsync(originals).Wait();
db.Commit();
}