I'm trying to get the last message sent to each customer. But I'm getting a NotSupportedException without any additional details. I'm unfamiliar with the join method of LINQ to NHibernate since this is the first time using it. Can someone please explain what is wrong with my query and why I'm getting this error? Here is my query and the error:
var messages = _session.Query<Communication>();
return messages.Join(
_session.Query<Communication>().GroupBy(m => m.Customer),
x => new { x.Customer, x.Message.CreatedOn },
g => new { Customer= g.Key, CreatedOn = g.Max(p => p.Message.CreatedOn) },
(x, g) => x)
.ToList();
System.NotSupportedException: query ( query ( select_from ( from ( range App.Core.Customer m ) ) ( select m ) ) )
Entities:
public class Communication
{
public Message Message { get; set; }
public Customer Customer { get; set; }
...
}
public class Message
{
public DateTime CreatedOn { get; set; }
public string Subject { get; set; }
public string Body { get; set; }
...
}