/// <summary> /// Re-insert the current instance after it has been deleted /// </summary> /// <param name="db"></param> public virtual void Undelete(Database db = null) { Type thisType = this.GetType(); if (db == null) { db = Database;// Db.For(thisType); } this.IsNew = true; ColumnAttribute[] columns = Db.GetColumns(thisType); foreach (ColumnAttribute col in columns) { this.SetValue(col.Name, this.GetCurrentValue(col.Name)); } this.Commit(); }
/// <summary> /// Undo any changes that have been made to the current instance /// since it was loaded. /// </summary> /// <param name="db"></param> public virtual void Undo(Database db = null) { Type thisType = this.GetType(); if (db == null) { db = Database; } SqlStringBuilder sql = GetSqlStringBuilder(db); ColumnAttribute[] columns = Db.GetColumns(thisType); foreach (ColumnAttribute col in columns) { this.SetValue(col.Name, this.GetOriginalValue(col.Name)); } AssignValue[] values = GetNewAssignValues(); sql.Update(this.TableName(), values) .Where(this.GetUniqueFilter()) .Go(); sql.Execute(db); }
protected ColumnAttribute[] GetColumns(Type daoType) { return(Db.GetColumns(daoType)); }