I can't get NHibernate to delete this child object, it completes without throwing any exceptions and without deleting anything:
public void DeleteW9(int vendorId, int vendorW9Id)
{
var vendor = vendorRepository.Get(vendorId);
var W9 = vendor.W9.Where(x => x.Id == vendorW9Id).First();
vendor.W9.Remove(W9);
vendorRepository.SaveOrUpdate(vendor);
}
Here's my Vendor mapping:
mapping.HasMany(x => x.W9)
.KeyColumn("VendorFk")
.Cascade.AllDeleteOrphan()
.AsBag();
My VendorW9 table contains a reference to the Vendor's ID in the form of the VendorFk. I have no restraints setup, do I need to setup a primary key relationship? NHibernate functions fine for everything but deleting orphans.