NHibernate Overcoming NotSupportedException

Posted by Jordan Wallwork on Stack Overflow See other posts from Stack Overflow or by Jordan Wallwork
Published on 2012-06-18T09:12:44Z Indexed on 2012/06/18 9:15 UTC
Read the original article Hit count: 275

Does anyone know of any way to overcome NotSupportedException? I have a method against a User:

 public virtual bool IsAbove(User otherUser)
 {
     return HeirarchyString.StartsWith(otherUser.HeirarchyString);
 }

And I want to do:

_session.Query<User>.Where(x => loggedInUser.IsAbove(x));

But this throws a NotSupportedException. The real pain though is that using

_session.Query<User>.Where(x => loggedInUser.HeirarchyString.StartsWith(x.HeirarchyString));

works absolutely fine. I don't like this as a solution, however, because it means that if I change how the IsAbove method works, I have to remember all the places where I have duplicated the code whenever I want to update it

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about nhibernate