コード例 #1
0
 /// <summary>
 /// Inserts a new record. There is no unique ID column so nothing is returned.
 /// </summary>
 /// <param name="connection"></param>
 /// <param name="transaction"></param>
 /// <param name="log"></param>
 /// <param name="dbInfo"></param>
 public void Insert(IDbConnection connection, IDbTransaction transaction, TextWriter log, BaseStationDBInfo dbInfo)
 {
     var preparedCommand = PrepareCommand(connection, transaction, "Insert", _InsertCommandText, 2);
     Sql.SetParameters(preparedCommand, dbInfo.OriginalVersion, dbInfo.CurrentVersion);
     Sql.LogCommand(log, preparedCommand.Command);
     preparedCommand.Command.ExecuteNonQuery();
 }
コード例 #2
0
        public void BaseStationDBInfo_Constructor_Initialises_To_Known_State_And_Properties_Work()
        {
            var dbInfo = new BaseStationDBInfo();

            TestUtilities.TestProperty(dbInfo, "CurrentVersion", 0, 126);
            TestUtilities.TestProperty(dbInfo, "OriginalVersion", 0, 28);
        }
コード例 #3
0
        private long AddDBInfo(BaseStationDBInfo dbInfo)
        {
            long result = 0;

            using(var connection = new SQLiteConnection(_ConnectionStringBuilder.ConnectionString)) {
                connection.Open();

                using(var command = connection.CreateCommand()) {
                    command.CommandText = "INSERT INTO [DBInfo] ([OriginalVersion], [CurrentVersion]) VALUES (?,?); SELECT last_insert_rowid();";
                    command.Parameters.Add(new SQLiteParameter() { Value = dbInfo.OriginalVersion });
                    command.Parameters.Add(new SQLiteParameter() { Value = dbInfo.CurrentVersion });

                    result = (long)command.ExecuteScalar();
                }
            }

            return result;
        }