public static void SaveUpdated(List<Base> source, string tableName, ref string errorMessage) { if (source.Count == 0) return; using (UtilityDb db = new UtilityDb()) { db.OpenConnectionESS(); // gather all the IDs of the edited items List<int> ids = new List<int>(); foreach (Base item in source) ids.Add(item.Id); string sql = "SELECT * FROM " + tableName + " WHERE ID in " + UtilityDb.InClause(ids); db.PrepareUpdate(sql); foreach (Base item in source) { DataRow row = db.FindRowFromID(item.Id, "ID"); if (row != null) item.Save(row); } db.EndUpdate(); } }
public void Update(string tablename) { using (UtilityDb db = new UtilityDb()) { db.OpenConnectionESS(); string sql = "SELECT * FROM " + tablename + " WHERE ID = " + Id; db.PrepareUpdate(sql); DataRow row = db.FindRowFromID(Id, "ID"); Save(row); db.EndUpdate(); } }