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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:26:52+00:00 2026-05-27T21:26:52+00:00

There is an entity Effort that has a property List and a property AdType

  • 0

There is an entity Effort that has a property List and a property AdType
We have several adTypes enum objects and specialLists enum objects to select IList<Effort>

I do it in this way:

    return NHibernateSession.QueryOver<Effort>()
        .JoinQueryOver(effort => effort.AdType)
                .WhereRestrictionOn(adType => adType.Id)
                .IsIn(adTypes.Select(adt => (long)adt).ToList())
            .Clone()
            .JoinQueryOver(effort => effort.List)
                .WhereRestrictionOn(list => list.Id)
                .IsIn(specialLists.Select(sl => (long)sl).ToList())
            .List<Effort>();

as u can see I use a strange Clone() method that doesn’t have any description. It works great.

In what way do you use QueryOver for such queries?

  • 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-27T21:26:52+00:00Added an answer on May 27, 2026 at 9:26 pm

    .JoinQueryOver(effort => effort.AdType) will return a QueryOver with a subtype, here AdType IQueryOver<Effort, Adtype> instead of the original IQueryOver<Effort, Effort>. The first generic argument is the queryType and the second the type on which the methods are operating on. If you clone in between the whole query is copyied and returned as the basequery IQueryOver<Effort, Effort>.

    To prevent the QueryOver to switch to the subtype there is JoinAlias which creates an alias instead of descending.

    AdType adAlias = null;
    ListType listAlias = null;
    
    return NHibernateSession.QueryOver<Effort>()
        .JoinAlias(effort => effort.AdType, () => adAlias)
        .JoinAlias(effort => effort.List, () => listAlias)
        .WhereRestrictionOn(() => adAlias.Id).IsIn(adTypes.Cast<long>().ToList())
        .WhereRestrictionOn(() => listAlias.Id).IsIn(specialLists.Cast<long>().ToList())
        .List<Effort>();
    

    not that if you only Restrict on the Id of adtype and listtype then

    return NHibernateSession.QueryOver<Effort>()
        .WhereRestrictionOn(effort => effort.Adtype.Id).IsIn(adTypes.Cast<long>().ToList())
        .WhereRestrictionOn(effort => effort.List.Id).IsIn(specialLists.Cast<long>().ToList())
        .List<Effort>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So there is an entity that has an enum property and a wcf service
There is Campaign Entity and for that, I have CampaignRepository which have this functions
I have an asp.net MVC application. There is an entity called File that it
For my application there are several entity classes, User, Customer, Post, and so on
There is need for quering NHibernate for several instances of the entity. I've tried
There's an Entity Class A. Class A might have children of the same type
I'm having bit complicated object model that forms a triangle. There is User entity
There is an entity type called Product that is generated by entity framework. I
I have entity A. Entity B inherits entity A. For entity B there are
I have an entity ,there is a array type attribute:productKey.I try to add a

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.