Pregunta

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

No hay solución correcta

Otros consejos

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top