本文整理汇总了C#中System.Data.IDbConnection.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# System.Data.IDbConnection.BeginTransaction方法的具体用法?C# System.Data.IDbConnection.BeginTransaction怎么用?C# System.Data.IDbConnection.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.IDbConnection
的用法示例。
在下文中一共展示了System.Data.IDbConnection.BeginTransaction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StorageHelper
public StorageHelper(System.Data.IDbConnection con)
{
m_connection = con;
m_previousTable = "Previous-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
m_currentTable = "Current-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
m_transaction = m_connection.BeginTransaction();
using(var cmd = m_connection.CreateCommand())
{
cmd.Transaction = m_transaction;
cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""Path"" TEXT NOT NULL, ""FileHash"" TEXT NULL, ""MetaHash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL, ""Type"" INTEGER NOT NULL) ", m_previousTable));
cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" (""Path"" TEXT NOT NULL, ""FileHash"" TEXT NULL, ""MetaHash"" TEXT NOT NULL, ""Size"" INTEGER NOT NULL, ""Type"" INTEGER NOT NULL) ", m_currentTable));
}
m_insertPreviousElementCommand = m_connection.CreateCommand();
m_insertPreviousElementCommand.Transaction = m_transaction;
m_insertPreviousElementCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""Path"", ""FileHash"", ""MetaHash"", ""Size"", ""Type"") VALUES (?,?,?,?,?)", m_previousTable);
m_insertPreviousElementCommand.AddParameters(5);
m_insertCurrentElementCommand = m_connection.CreateCommand();
m_insertCurrentElementCommand.Transaction = m_transaction;
m_insertCurrentElementCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" (""Path"", ""FileHash"", ""MetaHash"", ""Size"", ""Type"") VALUES (?,?,?,?,?)", m_currentTable);
m_insertCurrentElementCommand.AddParameters(5);
}
示例2: Basiclist
public Basiclist(System.Data.IDbConnection connection, string volumename)
{
m_connection = connection;
m_volumename = volumename;
m_transaction = m_connection.BeginTransaction();
var tablename = TABLE_PREFIX + "-" + Library.Utility.Utility.ByteArrayAsHexString(Guid.NewGuid().ToByteArray());
using(var cmd = m_connection.CreateCommand())
{
cmd.Transaction = m_transaction;
cmd.ExecuteNonQuery(string.Format(@"CREATE TEMPORARY TABLE ""{0}"" {1}", tablename, TABLEFORMAT));
m_tablename = tablename;
}
m_insertCommand = m_connection.CreateCommand();
m_insertCommand.Transaction = m_transaction;
m_insertCommand.CommandText = string.Format(@"INSERT INTO ""{0}"" {1}", m_tablename, INSERTCOMMAND);
m_insertCommand.AddParameters(INSERTARGUMENTS);
}