I have a query that resembles the following that I get a NotSupportedException ("Specified method is not supported") for. However, if I execute it at the Distinct()
and then perform the rest in memory, all is fine.
MySession.Query<Person>()
.Where(person => person.StatusId == 1)
.Select(person => person.Address)
.Distinct() // .ToList() here fixes it.
.OrderBy(address => address.Addr1)
.ToList();
Am I doing something illegal for nHibernate's Linq Provider here? If so, any idea how to manipulate this such that I can still run this in a server-side execution-deferred way? Ultimately, my query (Distinct()
and everything before that) is abstracted away from my code that performs the OrderBy
and ToList
.
I'm using:
NHibirnate has limitations on using DISTINCT and ORDER BY, http://www.ienablemuch.com/2010/12/performing-order-by-on-distinct-on-linq.html