Given a simplified model like the following:
public class Enquiry
{
public virtual DateTime Created { get; set; }
public virtual Sender Sender { get; set; }
}
public class Sender
{
public virtual IList<Enquiry> Enquiries { get; set; }
}
How can you construct a Linq to Nhibernate query such that it gives you back a list of senders and their enquiries where the enquiries meet some criteria. I have tried something like this:
return session.Linq<Enquiry>()
.Where(enquiry => enquiry.Created < DateTime.Now)
.Select(enquiry => enquiry.Sender)
In this case I get an InvalidCastException saying you can't cast type Sender to type Enquiry.
Any pointers on how I can do this without using HQL?