I'm adding a new method in my generic repository to delete a record directly from the db, instead of going through the DbConext
and then calling its SaveChanges
.
So I did:
public virtual void Delete(int id)
{
var connection = dataContext.GetDatabase().Connection;
var query = string.Format("DELETE FROM {0} WHERE id = {1}", tableName, id);
connection.Execute(query);
}
My current code that deletes entities using the DbContext
handles DbUpdateException
, and this exception bubbles up to the client.
Does Dapper's Execute
extension also throws this exception?