You seem to think that returning -1 indicates a problem. But according to the documentation Truncate
:
Removes all rows from a table or specified partitions of a table, without logging the individual row deletions.
And Dapper's Execute
method returns the rows affected.
So -1 seems reasonable to me.
Edit to add
After further investigation of the source code in GitHub, Dapper's Execute
extension under-the-hood calls SqlMapper's ExecuteImpl, which (due to the way it's called can only go two ways; but basically both) ends up returning the result of IDbCommand's ExecuteNonQuery
. So with that piece of the puzzle in place, Martin Smith's information from MSDN's ExecuteNonQuery applies:
For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value is -1