public void WriteSql(string sql, Dictionary <string, object> parameters) { if (sql.IsEmpty()) { throw new TfException("SQL not provided."); } if (this.SqlCommand == null) { this.SqlCommand = this.SqlConnection.CreateCommand(); } TfDebug.WriteLine("Executing query", sql); this.SqlCommand.CommandText = sql; if (parameters != null) { foreach (var parameter in parameters) { this.SqlCommand.Parameters.Add(ConnectProvider.SqlParameter(parameter.Key, parameter.Value)); } TfDebug.WriteLine("SQL Parameters", string.Join(Environment.NewLine, parameters)); } }
public Connect() { this.SqlConnection = ConnectProvider.SqlConnection(); }
public Connect(string sql, Dictionary <string, object> parameters) { this.SqlConnection = ConnectProvider.SqlConnection(); this.WriteSql(sql, parameters); }