From fc25f64feb4140332fd905e00226e3d4a126399c Mon Sep 17 00:00:00 2001 From: Russ Kollmansberger Date: Sun, 31 Aug 2025 12:20:22 -0500 Subject: [PATCH] Added method to apply delta SQL script including asynchronously --- Delta.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Delta.cs b/Delta.cs index e7fdb4b..4641f88 100644 --- a/Delta.cs +++ b/Delta.cs @@ -2,6 +2,7 @@ using System.Data; using System.Linq; using System.Text; +using System.Threading.Tasks; namespace DbTools { public class Delta { @@ -32,6 +33,21 @@ namespace DbTools { return BuildDelta(db1, db2, removeUnusedTables, removeUnusedColumns, removeUnusedTriggers, removeUnusedIndexes); } + public async Task ApplyDeltaAsync(IDbConnection cn, string sql) { + return await Task.Run(() => { + return ApplyDelta(cn, sql); + }); + } + + public bool ApplyDelta(IDbConnection cn, string sql) { + bool success = false; + using (var cmd = cn.CreateCommand()) { + cmd.CommandText = sql; + success = cmd.ExecuteNonQuery() > 0; + } + return success; + } + private string BuildDelta(Database db1, Database db2, bool removeUnusedTables, bool removeUnusedColumns, bool removeUnusedTriggers, bool removeUnusedIndexes) { StringBuilder sb = new StringBuilder();