Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
 public Connect()
 {
     this.SqlConnection = ConnectProvider.SqlConnection();
 }
Exemplo n.º 3
0
 public Connect(string sql, Dictionary <string, object> parameters)
 {
     this.SqlConnection = ConnectProvider.SqlConnection();
     this.WriteSql(sql, parameters);
 }