Nhibernate Cannot delete the child object
- by Daoming Yang
I know it has been asked for many times, i also have found a lot of answers on this website, but i just cannot get out this problem. 
Can anyone help me with this piece of code?
Many thanks. 
Here is my parent mapping file
<set name="ProductPictureList" table="[ProductPicture]" lazy="true" order-by="DateCreated" inverse="true" cascade="all-delete-orphan" >
  <key column="ProductID"/>
  <one-to-many class="ProductPicture"/>
</set>
Here is my child mapping file
<class name="ProductPicture" table="[ProductPicture]" lazy="true">
<id name="ProductPictureID">
  <generator class="identity" />
</id>
<property name="ProductID" type="Int32"></property>
<property name="PictureName" type="String"></property>
<property name="DateCreated" type="DateTime"></property>
</class>
Here is my c# code
        var item = _productRepository.Get(productID);
        var productPictrue = item.ProductPictureList
            .OfType<ProductPicture>()
            .Where(x => x.ProductPictureID == productPictureID);
        // reomve the finding item
        var ok =  item.ProductPictureList.Remove(productPictrue);
        _productRepository.SaveOrUpdate(item);
ok is false value and this child object is still in my database.