public static void UpdateNotForReplication(DbConnection sqlConnection, int[] ids, int userId) { var dbType = DatabaseTypeHelper.ResolveDatabaseType(sqlConnection); var setTrue = dbType == DatabaseType.SqlServer ? "1" : "true"; var sql = $@" UPDATE CONTENT_ITEM SET NOT_FOR_REPLICATION = {setTrue}, MODIFIED = {SqlQuerySyntaxHelper.Now(dbType)}, LAST_MODIFIED_BY = @userId WHERE {SqlQuerySyntaxHelper.IsFalse(dbType, "NOT_FOR_REPLICATION")} AND CONTENT_ITEM_ID IN (select id from {Common.IdList(dbType, "@ids")}); "; using (var cmd = DbCommandFactory.Create(sql, sqlConnection)) { cmd.Parameters.Add(SqlQuerySyntaxHelper.GetIdsDatatableParam("@ids", ids, dbType)); cmd.Parameters.AddWithValue("@userId", userId); cmd.ExecuteNonQuery(); } }
internal static string IsFalse(DatabaseType databaseType, string expr) => SqlQuerySyntaxHelper.IsFalse(databaseType, expr);