Retrieves a single entity by the specified primary key value from the database table.
- Parameters
-
| primary_key | The primary key value of the entity to be retrieved. |
- Returns
- The entity if found; otherwise, std::nullopt if the entity with the specified primary key value does not exist.
- Exceptions
-
- 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.
For more control over which entities to retrieve, use the MakeSelecter() method from the complex style interface to create a selecter and apply custom conditions. Furthermore, use the MakeSelecter(const COLUMNS&...) method to specify which columns of the entity to select.
- See also
- sqt::DataContext<>::MakeSelecter()
-
sqt::DataContext<>::MakeSelecter(const COLUMNS&... columns)
-
sqt::DataContext<>::SelectAll()
-
SQT_PRIMARY_KEY
-
SQT_PRIMARY_KEY_AUTO_INC