0

I have a self-referencing table which I use to build my tree view.

I use the following query to get the right structure:

  public IList<TreeNode> GetAllTreeNodes(string userid)
    {
        var query = Session.Query<TreeNode>()
                   .FetchMany(x => x.Children)
                   .Where(tn => (tn.User.Id == userid) && tn.IsDeleted == false);

        return query.ToList();
    }

The only problem with that is that my query ignores the IsDeleted flag of my children collection.

How can I tell NHibernate to query all my not deleted items and their corresponding not deleted children?

Cheers, Stefan

stefan
  • 1,336
  • 3
  • 21
  • 46

1 Answers1

1

You can define, per entity or per collection, a WHERE restriction, for example, "WHERE IS_DELETED = 0". See http://weblogs.asp.net/ricardoperes/archive/2013/03/21/soft-deletes-with-nhibernate.aspx.

Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74
  • Thanks for response! Wasn't aware that something like that exists... Going to investigate that ... – stefan Mar 07 '14 at 20:42