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.
nHibernate self referencing table fetch many
-
19-10-2022 - |
Question
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 correct solution
OTHER TIPS
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow