Exemple #1
0
        /// <summary>
        /// Deletes this item
        /// </summary>
        /// <returns></returns>
        /// <exception cref="AttributeNotFoundException">Class attribute parameter 'Mutable' must be seted to 'true'</exception>
        public virtual bool Delete()
        {
            ActiveRecordAttribute attribute = null;

            CheckTypeAtrribute(this.GetType(), ref attribute);

            if (!attribute.Mutable)
            {
                throw new AttributeNotFoundException("Class attribute parameter 'Mutable' must be seted to 'true'");
            }

            if (!ActiveRecordMaster.Delete(this.GetType(), this))
            {
                return(false);
            }

            //Cascade Delete
            if (ActiveRecordMaster.HasJoinedBase(this.GetType()) != null)
            {
                if (ActiveRecordMaster.GetAttribute(this.GetType().BaseType) != null)
                {
                    if (!ActiveRecordMaster.Delete(this.GetType().BaseType, this))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }