/// <summary> /// Execute parameterized SQL. /// For details, refer to the document of Dapper. /// </summary> /// <param name="cnn">Connection.</param> /// <param name="sql">Sql.</param> /// <param name="transaction">Transactions to be executed at the data source.</param> /// <param name="commandTimeout">Command timeout.</param> /// <param name="commandType">Command type.</param> /// <returns>Number of rows affected.</returns> public static Task <int> ExecuteAsync(this IDbConnection cnn, BuildedSql sql, IDbTransaction transaction = null, int?commandTimeout = default(int?), CommandType?commandType = default(CommandType?)) { //for testing. if (DapperAdapterTestPlugin.Execute != null) { return(Task.Factory.StartNew(() => DapperAdapterTestPlugin.Execute(cnn, sql))); } //debug. Debug(sql); try { var ret = DapperWrapperAsync.Execute(cnn, sql.Text, CreateDynamicParam(sql.GetParams()), transaction, commandTimeout, commandType); ResultLog?.Invoke(ret); return(ret); } catch (Exception e) { throw GetCoreException(e); } }