Question

I found some similar threads but all got my code as answer.

I am using One-to-Many relationship.

father mapping:

  HasMany(x => x.Targetings).KeyColumn("fk_campaign_id").Cascade.AllDeleteOrphan().Inverse().AsBag();

and the child is :

 References(x => x.NhCampaign).Column("fk_campaign_id");

where the father has a list of child. All is working - inserting and updating. but for some reason when I empty the list in the Father or just want to delete list item, it doesn't delete the child from the database. even if the list is empty.

this is how i update:

 using (ISession session = NHibernateHelper.OpenSession())
            {
                using (ITransaction transaction = session.BeginTransaction())
                {
                    session.Update(FatherObject);
                    //session.SaveOrUpdate(oCampaign);
                    transaction.Commit();
                }
            }

Am i doing something wrong here?

Was it helpful?

Solution

Got it using the Not.LazyLoad() method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top