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

◆ Update()

template<EntityValueType ENTITY>
bool sqt::DataContext< ENTITY >::Update ( const ENTITY & entity)

Updates the specified entity in the database table.

Parameters
entityThe entity to be updated. Its primary key value is used to identify the entity.
Returns
true if the entity was updated; otherwise, false if the entity does not exist in the table.
Exceptions
sqt::SQLErrorThrown if the update fails.
Note
This method is only available if the entity type has a primary key. Use the SQT_PRIMARY_KEY or SQT_PRIMARY_KEY_AUTO_INC macro to define a primary key.

This method updates the row whose primary key value matches the primary key value of the specified entity. All non-primary key columns will be updated. For more control over the update conditions or the specific columns to be updated, use the following methods from the complex style interface:

  • MakeUpdater() for creating an updater that updates all columns of the entity type and can be applied with update conditions.
  • MakeNoPrimaryKeyUpdater(), similar to MakeUpdater(), except that it updates only non-primary key columns.
  • MakeUpdater(ASSIGNMENTS&&...) for creating an updater that updates specific columns, and can also be applied with update conditions.
See also
sqt::DataContext<>::MakeNoPrimaryKeyUpdater()
sqt::DataContext<>::MakeUpdater()
sqt::DataContext<>::MakeUpdater(ASSIGNMENTS&&... assignments)
SQT_PRIMARY_KEY
SQT_PRIMARY_KEY_AUTO_INC