I want to delete a parent, and therefore all his children.

On 20 oct, 13:35, Patrick Steele <[email protected]> wrote:
> If you want the parent (and all children) deleted when a single child
> is deleted, just call your delete on the parent (instead of calling
> delete on the child):
>
> child.Sistema.Delete();
>
> ---
> Patrick Steelehttp://weblogs.asp.net/psteele
>
>
>
>
>
>
>
> On Wed, Oct 20, 2010 at 6:59 AM, oreo <[email protected]> wrote:
> > Hello. Sorry for my English.
> > I have a one to many, and I want to delete the parent when the child
> > is deleted.
>
> > When I try to delete a parent get the following error:
>
> > DELETE statement conflicted with the REFERENCE constraint
> > "FK58D3BC2BC5838F81." The conflict has appeared in the database
> > "NHibernate" table "dbo.Suscriptor", column 'system_id'.
> > Statement has been terminated.
>
> > [ActiveRecord]
> >    class Sistema : ActiveRecordBase<Sistema>
> >    {
> >        private int id;
>
> >        private IList<Suscriptor> suscriptores = new
> > List<Suscriptor>();
>
> >        public Sistema()
> >        {
> >        }
>
> >        [PrimaryKey("Id_Sistema")]
> >        public virtual int Id
> >        {
> >            get { return id; }
> >            set { id = value; }
> >        }
>
> >        [HasMany(Cascade = ManyRelationCascadeEnum.AllDeleteOrphan,
> > Inverse=true)]
> >        public virtual IList<Suscriptor> Suscriptores
> >        {
> >            get { return suscriptores; }
> >            set { suscriptores = value; }
> >        }
> >    }
>
> >    [ActiveRecord]
> >    class Suscriptor : ActiveRecordBase<Suscriptor>
> >    {
> >        private int id;
> >        private Sistema sistema;
>
> >        public Suscriptor()
> >        {
> >        }
>
> >        [PrimaryKey]
> >        public virtual int Id
> >        {
> >            get { return id; }
> >            set { id = value; }
> >        }
>
> >        [BelongsTo("Id_Sistema")]
> >        public virtual Sistema Sistema
> >        {
> >            get { return sistema; }
> >            set { sistema = value; }
> >        }
> >    }
>
> > Thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Castle Project Users" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/castle-project-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

Reply via email to