예제 #1
0
파일: Dao.cs 프로젝트: ThreeHeadz/Bam.Net
        /// <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();
        }
예제 #2
0
파일: Dao.cs 프로젝트: ThreeHeadz/Bam.Net
        /// <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);
        }
예제 #3
0
 protected ColumnAttribute[] GetColumns(Type daoType)
 {
     return(Db.GetColumns(daoType));
 }