SQT
A C++ ORM framework for SQLite
Loading...
Searching...
No Matches

◆ AutoIncReplace()

template<EntityValueType ENTITY>
std::int64_t sqt::DataContext< ENTITY >::AutoIncReplace ( const ENTITY & entity)

Inserts the specified entity into the database table, automatically generating the primary key value and replacing the existing row.

Parameters
entityThe entity to be inserted.
Returns
The generated row ID of the inserted entity.
Exceptions
sqt::SQLErrorThrown if the insertion fails.

This method is similar to the AutoIncInsert() method, except that it replaces the existing row if an unique constraint violation occurs.

Note
This method is only available if the entity type has an auto-incremented primary key. Use the SQT_PRIMARY_KEY_AUTO_INC macro to define an auto-incremented primary key.
See also
sqt::DataContext<>::AutoIncInsert()
sqt::DataContext<>::MakeAutoIncReplacer()
SQT_PRIMARY_KEY_AUTO_INC