Esempio n. 1
0
 /// <summary> Sqlite 3 last insert rowid. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <exception cref="ArgumentException"> Thrown when one or more arguments have unsupported or
 ///     illegal values. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="isMaintenanceDb"> (Optional) True if this object is maintenance database. </param>
 /// <returns> A long. </returns>
 internal long sqlite3_last_insert_rowid(SqliteDatabaseHandle db, bool isMaintenanceDb = false)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     lock (_stepLocker) {
         DbProvider.sqlite3 database = (isMaintenanceDb ? db.MaintenanceDb : db.Db)
                                       ?? throw new ArgumentException((isMaintenanceDb
                                               ? "Maintenance mode is specified, but the database is not in Maintenance Mode."
                                               : "The database is in Maintenance Mode, but this was not properly specified."),
                                                                      nameof(isMaintenanceDb));
         return(DbProviderOperations.sqlite3_last_insert_rowid(database));
     }
 }
Esempio n. 2
0
 /// <summary> Sqlite 3 step return rowid. </summary>
 /// <exception cref="ArgumentNullException"> Thrown when one or more required arguments are null. </exception>
 /// <param name="db"> The database. </param>
 /// <param name="stmt"> The statement. </param>
 /// <param name="code"> [out] The code. </param>
 /// <returns> A long. </returns>
 internal long sqlite3_step_return_rowid(SqliteDatabaseHandle db, SqliteStatementHandle stmt, out SqliteResultCode code)
 {
     if (db == null)
     {
         throw new ArgumentNullException(nameof(db));
     }
     if (stmt == null)
     {
         throw new ArgumentNullException(nameof(stmt));
     }
     lock (_stepLocker) {
         stmt.CheckMaintenanceMode();
         code = (SqliteResultCode)DbProviderOperations.sqlite3_step(stmt.Statement);
         return(code.IsSuccessCode()
             ? DbProviderOperations.sqlite3_last_insert_rowid(stmt.ForMaintenance ? db.MaintenanceDb : db.Db)
             : -1);
     }
 }