本文整理汇总了C#中SQLiteConnection.ChangesCount方法的典型用法代码示例。如果您正苦于以下问题:C# SQLiteConnection.ChangesCount方法的具体用法?C# SQLiteConnection.ChangesCount怎么用?C# SQLiteConnection.ChangesCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQLiteConnection
的用法示例。
在下文中一共展示了SQLiteConnection.ChangesCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestChangesCount
public void TestChangesCount()
{
var initialChangesCount = 0;
var insertChangesCount = 0;
var numRecords = this.rnd.Next(1, 11);
var insertedRecords = new List<Tuple<int, long, string, double>>(numRecords);
for (var i = 0; i < numRecords; i++)
{
insertedRecords.Add(new Tuple<int, long, string, double>(i, this.GetRandomInteger(), this.GetRandomString(), this.GetRandomReal()));
}
using (var connection = new SQLiteConnection(this.databaseRelativePath))
{
using (var statement = connection.Prepare("DROP TABLE IF EXISTS TestQuery;"))
{
statement.Step();
}
using (var statement = connection.Prepare("CREATE TABLE TestQuery(id INTEGER, i INTEGER, t TEXT, r REAL);"))
{
statement.Step();
}
initialChangesCount = connection.ChangesCount();
foreach (var record in insertedRecords)
{
var command = "INSERT INTO TestQuery(id, i, t, r) VALUES(" + record.Item1.ToString(this.invClt) + "," + record.Item2.ToString(this.invClt)
+ ",'" + record.Item3 + "'," + record.Item4.ToString(this.invClt) + ");";
using (var statement = connection.Prepare(command))
{
statement.Step();
}
insertChangesCount += connection.ChangesCount();
}
using (var statement = connection.Prepare("DROP TABLE TestQuery;"))
{
statement.Step();
}
}
Assert.AreEqual(0, initialChangesCount);
Assert.AreEqual(insertedRecords.Count, insertChangesCount);
}