Interface IEntityManipulator

Namespace
RentADeveloper.DbConnectionPlus.DatabaseAdapters
Assembly
RentADeveloper.DbConnectionPlus.dll

Provides CRUD database operations for entities.

public interface IEntityManipulator

Methods

DeleteEntitiesAsync<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Asynchronously deletes the specified entities, identified by their key property/properties, from the database.

Task<int> DeleteEntitiesAsync<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to delete the entities.

entities IEnumerable<TEntity>

The entities to delete.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows affected by the delete operation.

Type Parameters

TEntity

The type of entities to delete.

Remarks

The table from which the entities will be deleted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while deleting an entity. A concurrency violation occurs when an unexpected number of rows are affected by a delete operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

DeleteEntities<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Deletes the specified entities, identified by their key property/properties, from the database.

int DeleteEntities<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to delete the entities.

entities IEnumerable<TEntity>

The entities to delete.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows affected by the delete operation.

Type Parameters

TEntity

The type of entities to delete.

Remarks

The table from which the entities will be deleted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while deleting an entity. A concurrency violation occurs when an unexpected number of rows are affected by a delete operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

DeleteEntityAsync<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Asynchronously deletes the specified entity, identified by its key property / properties, from the database.

Task<int> DeleteEntityAsync<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to delete the entity.

entity TEntity

The entity to delete.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows affected by the delete operation.

Type Parameters

TEntity

The type of entity to delete.

Remarks

The table from which the entity will be deleted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while deleting an entity. A concurrency violation occurs when an unexpected number of rows are affected by a delete operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

DeleteEntity<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Deletes the specified entity, identified by its key property / properties, from the database.

int DeleteEntity<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to delete the entity.

entity TEntity

The entity to delete.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows affected by the delete operation.

Type Parameters

TEntity

The type of entity to delete.

Remarks

The table from which the entity will be deleted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while deleting an entity. A concurrency violation occurs when an unexpected number of rows are affected by a delete operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

InsertEntitiesAsync<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Asynchronously inserts the specified entities into the database.

Task<int> InsertEntitiesAsync<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to insert the entities.

entities IEnumerable<TEntity>

The entities to insert.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows that were affected by the insert operation.

Type Parameters

TEntity

The type of entities to insert.

Remarks

The table into which the entities will be inserted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not inserted.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not inserted. Once an entity is inserted, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
OperationCanceledException

The operation was cancelled via cancellationToken.

InsertEntities<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Inserts the specified entities into the database.

int InsertEntities<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to insert the entities.

entities IEnumerable<TEntity>

The entities to insert.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows that were affected by the insert operation.

Type Parameters

TEntity

The type of entities to insert.

Remarks

The table into which the entities will be inserted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not inserted.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not inserted. Once an entity is inserted, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
OperationCanceledException

The operation was cancelled via cancellationToken.

InsertEntityAsync<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Asynchronously inserts the specified entity into the database.

Task<int> InsertEntityAsync<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to insert the entity.

entity TEntity

The entity to insert.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows that were affected by the insert operation.

Type Parameters

TEntity

The type of entity to insert.

Remarks

The table into which the entity will be inserted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not inserted.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not inserted. Once an entity is inserted, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
OperationCanceledException

The operation was cancelled via cancellationToken.

InsertEntity<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Inserts the specified entity into the database.

int InsertEntity<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to insert the entity.

entity TEntity

The entity to insert.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows that were affected by the insert operation.

Type Parameters

TEntity

The type of entity to insert.

Remarks

The table into which the entity will be inserted can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not inserted.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not inserted. Once an entity is inserted, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
OperationCanceledException

The operation was cancelled via cancellationToken.

UpdateEntitiesAsync<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Asynchronously updates the specified entities, identified by their key property / properties, in the database.

Task<int> UpdateEntitiesAsync<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to update the entities.

entities IEnumerable<TEntity>

The entities to update.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows that were affected by the update operation.

Type Parameters

TEntity

The type of entities to update.

Remarks

The table in which the entities will be updated can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not updated.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not updated. Once an entity is updated, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentException

No instance property (with a public getter) of the type TEntity is denoted with a KeyAttribute.

ArgumentNullException
DbUpdateConcurrencyException

A concurrency violation was encountered while updating an entity. A concurrency violation occurs when an unexpected number of rows are affected by an update operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

UpdateEntities<TEntity>(DbConnection, IEnumerable<TEntity>, DbTransaction?, CancellationToken)

Updates the specified entities, identified by their key property / properties, in the database.

int UpdateEntities<TEntity>(DbConnection connection, IEnumerable<TEntity> entities, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to update the entities.

entities IEnumerable<TEntity>

The entities to update.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows that were affected by the update operation.

Type Parameters

TEntity

The type of entities to update.

Remarks

The table in which the entities will be updated can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not updated.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not updated. Once an entity is updated, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentException

No instance property of the type TEntity is configured as a key property.

ArgumentNullException
DbUpdateConcurrencyException

A concurrency violation was encountered while updating an entity. A concurrency violation occurs when an unexpected number of rows are affected by an update operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

UpdateEntityAsync<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Asynchronously updates the specified entity, identified by its key property / properties, in the database.

Task<int> UpdateEntityAsync<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to update the entity.

entity TEntity

The entity to update.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

Task<int>

A task representing the asynchronous operation. Result will contain the number of rows that were affected by the update operation.

Type Parameters

TEntity

The type of entity to update.

Remarks

The table in which the entity will be updated can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not updated.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not updated. Once an entity is updated, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while updating an entity. A concurrency violation occurs when an unexpected number of rows are affected by an update operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.

UpdateEntity<TEntity>(DbConnection, TEntity, DbTransaction?, CancellationToken)

Updates the specified entity, identified by its key property / properties, in the database.

int UpdateEntity<TEntity>(DbConnection connection, TEntity entity, DbTransaction? transaction, CancellationToken cancellationToken)

Parameters

connection DbConnection

The database connection to use to update the entity.

entity TEntity

The entity to update.

transaction DbTransaction

The database transaction within to perform the operation.

cancellationToken CancellationToken

A token that can be used to cancel the operation.

Returns

int

The number of rows that were affected by the update operation.

Type Parameters

TEntity

The type of entity to update.

Remarks

The table in which the entity will be updated can be configured via TableAttribute or Configure(Action<DbConnectionPlusConfiguration>). Per default, the singular name of the type TEntity is used as the table name.

The type TEntity must have at least one instance property configured as key property. Use KeyAttribute or Configure(Action<DbConnectionPlusConfiguration>) to configure key properties.

Per default, each instance property of the type TEntity is mapped to a column with the same name (case-sensitive) in the table. This can be configured via ColumnAttribute or Configure(Action<DbConnectionPlusConfiguration>).

The columns must have data types that are compatible with the property types of the corresponding properties. The compatibility is determined using CanConvert(Type, Type).

Properties configured as ignored properties (via NotMappedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are not updated.

Properties configured as identity or computed properties (via DatabaseGeneratedAttribute or Configure(Action<DbConnectionPlusConfiguration>)) are also not updated. Once an entity is updated, the values for these properties are retrieved from the database and the entity properties are updated accordingly.

Exceptions

ArgumentNullException
ArgumentException

No instance property of the type TEntity is configured as a key property.

DbUpdateConcurrencyException

A concurrency violation was encountered while updating an entity. A concurrency violation occurs when an unexpected number of rows are affected by an update operation. This is usually because the data in the database has been modified since the entity has been loaded.

OperationCanceledException

The operation was cancelled via cancellationToken.