title: Problem Deleting with Parent/Child
body: <p>I have an issue when deleting a child record from the session.  Here are the entities i have defined:</p>
  
  <pre><code>public class ReportedData
  {
      public virtual int ReportedDataID { get; set; }
      public virtual ReportedDataTypes Type { get; set; }
      public virtual string Reason { get; set; }
  
      public virtual IList&lt;ArticleCommentReported&gt; ArticleCommentsReported { get; private set; }
      public virtual IList&lt;ForumPostReported&gt; ForumPostsReported { get; private set; }
  
      public ReportedData()
      {
          ArticleCommentsReported = new List&lt;ArticleCommentReported&gt;();
          ForumPostsReported = new List&lt;ForumPostReported&gt;();
      }
  }
  
  public class ArticleCommentReported : ReportedData
  {
      public virtual ArticleComment Comment { get; set; }
  }
  
  public class ForumPostReported : ReportedData
  {
      public virtual ForumPost Post { get; set; }
  }
  </code></pre>
  
  <p>With the following fluent mapping:</p>
  
  <pre><code>public ReportedDataMap()
  {
      Table("ReportedData");
      Id(x =&gt; x.ReportedDataID);
      Map(x =&gt; x.Type, "TypeID");
      Map(x =&gt; x.Reason);
      HasMany(x =&gt; x.ArticleCommentsReported)
          .KeyColumn("ReportedDataID")
          .Inverse()
          .Cascade.All();
      HasMany(x =&gt; x.ForumPostsReported)
          .KeyColumn("ReportedDataID")
          .Inverse()
          .Cascade.All();
  }
  
  public class ArticleCommentReportedMap : SubclassMap&lt;ArticleCommentReported&gt;
  {
      public ArticleCommentReportedMap()
      {
          Table("ArticleCommentsReported");
          KeyColumn("ReportedDataID");
          References(x =&gt; x.Comment, "CommentID");
      }
  }
  
  public class ForumPostReportedMap : SubclassMap&lt;ForumPostReported&gt;
  {
      public ForumPostReportedMap()
      {
          Table("ForumPostsReported");
          KeyColumn("ReportedDataID");
          References(x =&gt; x.Post, "PostID");
      }
  }
  </code></pre>
  
  <p>Now say i try the following (i have added comments to help you understand what's going on):</p>
  
  <pre><code>// Loop over the reported data (this is my view model and not my actual model which contains an extra property for the action they wish to carry out)
  foreach (var reportedData in model)
  {
      // If the action is leave then do nothing (else we always delete the reported data)
      if (reportedData.Action != ReportedDataActions.Leave)
      {
          // Switch over the type since we need to make sure it deletes the article comment or post if the action is set to delete
          switch (reportedData.Type)
          {
              case ReportedDataTypes.ArticleComment:
                  var reportedComment = _context.Repository&lt;ArticleCommentReported&gt;().GetByID(reportedData.ReportedDataID);
  
                  if (reportedData.Action == ReportedDataActions.Delete)
                      _context.Repository&lt;ArticleComment&gt;().Delete(reportedComment.Comment);
  
                  _context.Repository&lt;ArticleCommentReported&gt;().Delete(reportedComment);
  
                  break;
              case ReportedDataTypes.ForumPost:
                  var reportedPost = _context.Repository&lt;ForumPostReported&gt;().GetByID(reportedData.ReportedDataID);
  
                  if (reportedData.Action == ReportedDataActions.Delete)
                      _forumService.DeletePost(reportedPost.Post);
  
                  _context.Repository&lt;ForumPostReported&gt;().Delete(reportedPost);
  
                  break;
          }
      }
  }
  
  _context.Commit();
  </code></pre>
  
  <p>When the user trys to delete a forum post (the Action against the reported data is set to delete) it throws the following error:</p>
  
  <p>Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [ForumPostReported#2]</p>
  
  <p>I could probably set some mapping up to automatically delete the post/comment once the reported data is deleted but i only want to delete the post/comment if the action is set to delete.</p>
  
  <p>I'd appreciate it if someone could help.  Thanks</p>