Generates queries of the form UPDATE tablename SET field1 = value1, field2 = value2 ... fieldN = valueN WHERE [filter].

To determine updated field values, Set(field, value) should be called several times.

Where expressions determines the record(s) to update.

Inheritance: QueryWithParams, ISetFieldByStatement, IFilterableQuery
Beispiel #1
0
 public void Add(SqlUpdate statement)
 {
     AddCommandWithParameters(statement.ToString(), statement.Params);
 }
Beispiel #2
0
 /// <summary>
 ///   Clones this SqlUpdate query.</summary>
 /// <returns>
 ///   A new clone.</returns>
 public SqlUpdate Clone()
 {
     SqlUpdate clone = new SqlUpdate(_tableName);
     clone._nameValuePairs.AddRange(this._nameValuePairs);
     clone._where.Append(this._where.ToString());
     if (this._params != null)
     {
         clone._params = new Dictionary();
         foreach (var pair in this._params)
             clone._params.Add(pair.Key, pair.Value);
     }
     return clone;
 }
Beispiel #3
0
 /// <summary>
 ///   <see cref="SqlUpdate"/> nesnesinin içerdiği sorguyu bağlantı üzerinde çalıştırır.</summary>
 /// <remarks>
 ///   <p>Bu bir extension metodu olduğundan direk query.Execute(connection) şeklinde de
 ///   çalıştırılabilir.</p></remarks>
 /// <param name="connection">
 ///   Sorgunun çalıştırılacağı bağlantı. Gerekirse otomatik olarak açılır.</param>
 /// <param name="query">
 ///   Sorguyu içeren <see cref="SqlUpdate"/> nesnesi.</param>
 /// <returns>
 ///   Etkilenen kayıt sayısı.</returns>
 public static int Execute(this SqlUpdate query, IDbConnection connection, ExpectedRows expectedRows = ExpectedRows.One)
 {
     return(CheckExpectedRows(expectedRows, ExecuteNonQuery(connection, query.ToString(), query.Params)));
 }