sdk/dotnet/src/Microsoft.Datasync.Client.SQLiteStore/Utils/SqlStatements.cs
/// <summary>
/// Creates a <c>UPDATE {table} SET WHERE</c> SQL statement.
/// </summary>
/// <param name="tableName">The name of the table.</param>
/// <param name="item">The item to update.</param>
/// <param name="parameters">On completion, a list of parameters for the SQL statement.</param>
/// <returns>The SQL statement.</returns>
Creates a UPDATE {table} SET WHERE
Creates a UPDATE { table } SET WHERE
internal static string BatchUpdate(string tableName, List<ColumnDefinition> columns, JObject item, out Dictionary<string, object> parameters)
        {
            StringBuilder sql = new($"UPDATE {FormatTableName(tableName)} SET ");
            var updateParams = new Dictionary<string, object>();
            ColumnDefinition idColumn = columns.Find(c => c.IsIdColumn);
            if (idColumn == null)
            {
                parameters = null;
                return null;
            }
            List<string> updates = new();
            foreach (var column in columns.Where(c => !c.IsIdColumn))
            {
                string paramName = AddParameter(item, column, updateParams);
                updates.Add($"{FormatColumnName(column.Name)} = {paramName}");
            }
            sql.Append(string.Join(",", updates));
            sql.Append(" WHERE ").Append(FormatColumnName(idColumn.Name)).Append(" = ").Append(AddParameter(item, idColumn, updateParams));
            parameters = updateParams;
            return sql.ToString();
        }
internal static string BatchUpdate ( string tableName , List < ColumnDefinition > columns , JObject item , out Dictionary < string , object > parameters ) { StringBuilder sql = new ( $" UPDATE  { FormatTableName ( tableName ) }  SET  " ) ; var updateParams = new Dictionary < string , object > ( ) ; ColumnDefinition idColumn = columns . Find ( c => c . IsIdColumn ) ; if ( idColumn == null ) { parameters = null ; return null ; } List < string > updates = new ( ) ; foreach ( var column in columns . Where ( c => ! c . IsIdColumn ) ) { string paramName = AddParameter ( item , column , updateParams ) ; updates . Add ( $" { FormatColumnName ( column . Name ) }  =  { paramName } " ) ; } sql . Append ( string . Join ( " " , updates ) ) ; sql . Append ( " " ) . Append ( FormatColumnName ( idColumn . Name ) ) . Append ( " " ) . Append ( AddParameter ( item , idColumn , updateParams ) ) ; parameters = updateParams ; return sql . ToString ( ) ; }
Creates a UPDATE {table} SET WHERE
Creates a UPDATE { table } SET WHERE
The SQL statement.
The SQL statement .
tableName
string
The name of the table.
The name of the table .
columns
List<ColumnDefinition>
item
JObject
The item to update.
The item to update .
Dictionary<string, object>
out
parameters
On completion, a list of parameters for the SQL statement.
On completion a list of parameters for the SQL statement .