GetLastAutoIncrementingID() public method

Gets the value of the last auto-incrementing number. This called after doing an insert statement so that the inserted auto-number can be retrieved. The table name, current IDbTransaction and IDbCommand are passed in so that they can be used if necessary. Note_, this must be overridden in subclasses to include support for this feature in different databases - otherwise a NotImplementedException will be thrown.
public GetLastAutoIncrementingID ( string tableName, IDbTransaction tran, IDbCommand command ) : long
tableName string The name of the table inserted into
tran IDbTransaction The current transaction, the one the insert was done in
command IDbCommand The Command the did the insert statement
return long
Exemplo n.º 1
0
 /// <summary>
 /// Carries out instructions after execution of the sql statement
 /// </summary>
 /// <param name="databaseConnection">The <see cref="DatabaseConnection"/> that executed the statement.</param>
 /// <param name="transaction">The <see cref="IDbTransaction"/> under which the <see cref="SqlStatement"/>'s command was run.</param>
 /// <param name="command">The <see cref="IDbCommand"/> that was used to execute the <see cref="SqlStatement"/>.</param>
 internal override void DoAfterExecute(DatabaseConnection databaseConnection, IDbTransaction transaction, IDbCommand command)
 {
     if (_supportsAutoIncrementingFIELD != null && _tableName != null)
     {
         var lastAutoIncrementingID = databaseConnection.GetLastAutoIncrementingID(_tableName, transaction, command);
         _supportsAutoIncrementingFIELD.SetAutoIncrementingFieldValue(lastAutoIncrementingID);
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Carries out instructions after execution of the sql statement
 /// </summary>
 /// <param name="databaseConnection">The <see cref="DatabaseConnection"/> that executed the statement.</param>
 /// <param name="transaction">The <see cref="IDbTransaction"/> under which the <see cref="SqlStatement"/>'s command was run.</param>
 /// <param name="command">The <see cref="IDbCommand"/> that was used to execute the <see cref="SqlStatement"/>.</param>
 internal override void DoAfterExecute(DatabaseConnection databaseConnection, IDbTransaction transaction, IDbCommand command)
 {
     if (_supportsAutoIncrementingFIELD != null && _tableName != null)
     {
         var lastAutoIncrementingID = databaseConnection.GetLastAutoIncrementingID(_tableName, transaction, command);
         _supportsAutoIncrementingFIELD.SetAutoIncrementingFieldValue(lastAutoIncrementingID);
     }
 }