What is the correct translation of this LINQ to SQL query in NHibernate using the Criteria API?
var result = from e in Employees
where e.WorkTimeEntries.Any(t => t.DateTime >= new DateTime(2012, 3, 1))
select e;
I have tried:
var employees = Session.QueryOver<Employee>();
var timeWorkedAlias = new HashedSet<WorkTimeEntry>();
var timeWorked = employees.Left.JoinQueryOver(e => e.WorkTimes,
() => timeWorkedAlias);
timeWorkedAlias.Where (wa => wa.DateTime >= new DateTime(2012,3,1));
// How do to include the timeWorkedAlias 'filter' in the query?
var result = employees.List();
I am missing a couple of steps to include the date filter to be included in the query.
I think I manage to find the answer (with help from Andre)
This seems to work:
The trick is to specify
JoinQueryOver<WorkTimeEntry>According to QueryOver in NH 3.0