Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7584375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:54:20+00:00 2026-05-30T18:54:20+00:00

What is the correct translation of this LINQ to SQL query in NHibernate using

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:54:21+00:00Added an answer on May 30, 2026 at 6:54 pm

    I think I manage to find the answer (with help from Andre)

    This seems to work:

    var result = Session.QueryOver<Employee>()
     .JoinQueryOver<WorkTimeEntry>(e => e.WorkTimes)
     .Where(t => t.DateTime > new DateTime(2012,3,1))
     .List();
    

    The trick is to specify JoinQueryOver<WorkTimeEntry>

    According to QueryOver in NH 3.0

    Note, the overload for JoinQueryOver takes an IEnumerable, and the
    C# compiler infers the type from that. If your collection type is not
    IEnumerable, then you need to qualify the type of the sub-criteria:

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to run a LINQ query like this: var words = from
First of all I do not know if this is the correct translation for
Please correct me if I am wrong, but is one complex query less expensive
What is the correct syntax for Minus Query in MS ACCESS I want to
How would you correct way to handle an exception in this situation? Initially I
What would be the correct translation of the following Python method to Ruby? def
Iam using a mixed approach of manual language translation, and google translation using jquery-translate
I have been playing about with LINQ-SQL, trying to get re-usable chunks of expressions
Code: public IList<T> GetByMultipleIds(int[] ids) { List<T> result = _session.Linq<T>() .Where(x => ids.Contains(x.Id)).ToList(); return
I've been trying to figure this problem out all morning. Tried some things from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.