当前位置: 首页>>代码示例>>C#>>正文


C# System.Data.IDbConnection.BeginTransaction方法代码示例

本文整理汇总了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);
 }
开发者ID:AlexFRAN,项目名称:duplicati,代码行数:26,代码来源:LocalListChangesDatabase.cs

示例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);
            }
开发者ID:HITSUN2015,项目名称:duplicati,代码行数:19,代码来源:LocalTestDatabase.cs


注:本文中的System.Data.IDbConnection.BeginTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。