Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dapper. What Exceptions does conn.Execute throw?

I'm using dapper.net and I've wrapped connection.Execute for my Delete and Update statements.

public virtual void Update(TEntity entity)
{
    IDbConnection connection = connectionService.Connection;

    connection.Execute(UpdateQuery, entity, connectionService.Transaction);
}

When I've come to use this, I want to know if it fails or not by catching an exception(s) and not just a general Exception. Which (if any) exceptions are thrown? I would assume SqlException, but a previous manager taught me to assume nothing.

Can anybody point me in the right direction as to where I find this information?

like image 442
Jack Pettinger Avatar asked Jul 17 '15 12:07

Jack Pettinger


People also ask

What exceptions does dapper throw?

Dapper will indeed throw SqlException when used against a SqlConnection. The exceptions will be consistent with those that you will get from vanilla ADO.NET code. With a value that is the code of the specific SQL exception type. Dapper will indeed throw SqlException when used against a SqlConnection.

What is splitOn in dapper?

splitOn: CustomerId will result in a null customer name. If you specify CustomerId,CustomerName as split points, dapper assumes you are trying to split up the result set into 3 objects. First starts at the beginning, second starts at CustomerId , third at CustomerName . Follow this answer to receive notifications.

What is the use of dapper in C#?

Dapper is a micro ORM or it is a simple object mapper framework which helps to map the native query output to a domain class or a C# class. It is a high performance data access system built by StackOverflow team and released as open source.


1 Answers

Dapper will indeed throw SqlException when used against a SqlConnection.

The exceptions will be consistent with those that you will get from vanilla ADO.NET code. With a value that is the code of the specific SQL exception type.

like image 103
JDTLH9 Avatar answered Sep 17 '22 13:09

JDTLH9