I am a vb.net guy and it is hard for me to read C #. I compiled C # Dapper in a DLL and used it in my application. My main problem is that I need to change the source code for the default integration of the Transaction Fault Handling Framework for SQL Azure in every SQL query.
I can add retry logic at the connection level because it is on top of the dapper top, but not at the runtime level that is built into the drapper class.
Has anyone else done this?
* UPDATE *
Does only ReliableSqlConnection use on top of the call does Dapper handle retry logic when executing a query without a query?
Here is a sample retry code from MS with transietn fault
using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.AzureStorage; using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.TransientFaultHandling.SqlAzure; using System.Data; ... using (ReliableSqlConnection conn = new ReliableSqlConnection(connString, retryPolicy)) { conn.Open(); IDbCommand selectCommand = conn.CreateCommand(); selectCommand.CommandText = "UPDATE Application SET [DateUpdated] = getdate()";
Here is the Dapper code execution part, the same name is used, but I think this is a custom execution function
private static int ExecuteCommand(IDbConnection cnn, IDbTransaction transaction, string sql, Action<IDbCommand, object> paramReader, object obj, int? commandTimeout, CommandType? commandType) { IDbCommand cmd = null; bool wasClosed = cnn.State == ConnectionState.Closed; try { cmd = SetupCommand(cnn, transaction, sql, paramReader, obj, commandTimeout, commandType); if (wasClosed) cnn.Open(); return cmd.ExecuteNonQuery(); } finally { if (wasClosed) cnn.Close(); if (cmd != null) cmd.Dispose(); } }
source share