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 7623323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:40:41+00:00 2026-05-31T04:40:41+00:00

Hi all NHibernate gurus ! Given these two classes : public class User {

  • 0

Hi all NHibernate gurus !

Given these two classes :

public class User {
    long Id;
    string Name;
}

public class Project {
    long Id;
    User Owner;
    IList<User> Managers;
    ...
}

I would like to do a query using QueryOver (not using criteria “magic string” aliases), to get all projects having user1 as Owner OR as one of the Managers.

I know how to separately :

  • get projects having user1 as Owner : session.QueryOver<>Project>>().Where(p=>p.Owner == user1)
  • get as a manager : session.QueryOver<>().JoinAlias(p=>p.Managers, ()=>manager).Where(()=>manager == user1)

but I don’t know how to write the disjunction.

If someone had an idea, it would help me a lot.

Thanks in advance,

Chris

  • 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-31T04:40:42+00:00Added an answer on May 31, 2026 at 4:40 am

    Something like:-

    User manager = null;
    
    var query = session
        .QueryOver<Project>()
        .JoinAlias(j => j.Managers, () => manager)
        .Where(w => manager.Name == user1 || w.Owner == user1)
        .List<Project>();
    

    edit to change filter from Name to Id (as OP pointed out):-

    .Where(w=>manager.Id == user1.Id || w.Owner.Id == user1.Id)
    

    edit2 to change inner to left use

    .JoinAlias(j => j.Managers, () => manager).left
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use NHibernate in a project. All my domain tables include a
Hey all, quick NHibernate question. In my current project, we have a denormalized table
I know that all members of a POCO class for NHibernate must be defined
I have a Data project that has all my nhibernate mappings, and my Repositories
I have an MVC3 project using nHibernate, Rhino and Castle. I finally got all
I've got a class library doing all my NHibernate stuff. It also handles all
Having created a functional test project using nHibernate with all the typical trimmings I've
When creating a criteria for NHibernate all criteria are added as AND . For
Does nHibernate create code that has all the details of the column? I know
NHibernate is not really a good fit for our environment due to all the

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.