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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:39:22+00:00 2026-05-25T11:39:22+00:00

This NHibernate blog entry notes how detached QueryOver queries (analogous to DetachedCriteria ) can

  • 0

This NHibernate blog entry notes how detached QueryOver queries (analogous to DetachedCriteria) can be created (using QueryOver.Of<T>()). However, looking this over, it doesn’t look analogous to me at all.

With DetachedCriteria, I would create my instance and set it up however I need, and afterwards call GetExecutableCriteria() to then assign the session and execute the query. With the “detached” QueryOver, most of the API is unavailable (ie, to add restrictions, joins, ordering, etc…) until I call GetExecutableQueryOver, which requires takes an ISession or IStatelessSession, at which point you are no longer disconnected.

How do you work with detached QueryOver instances?

EDIT:

Actual problem was related to how I’m storing the detached QueryOver instance:

public class CriteriaQuery<T>
{
    internal protected QueryOver<T> _QueryOver { get; set; }

    public CriteriaQuery()
    {
        _QueryOver = QueryOver.Of<T>();
    }

    // Snip
}

It should be a QueryOver<T, T>.

  • 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-25T11:39:23+00:00Added an answer on May 25, 2026 at 11:39 am

    I’m using NHibernate 3.1.0.4000. The following code compiles successfully:

    Employee salesRepAlias = null;
    
    var query = QueryOver.Of<Customer>()
        .JoinAlias(x => x.SalesRep, () => salesRepAlias)
        .Where(x => x.LastName == "Smith")
        .Where(() => salesRepAlias.Office.Id == 23)
        .OrderBy(x => x.LastName).Asc
        .ThenBy(x => x.FirstName).Asc;
    
    return query.GetExecutableQueryOver(session)
        .List();
    

    This illustrates using restrictions, joins, and ordering on a detached QueryOver just like you would with a regular one.

    Could you please post the code that demonstrates the API features that are unavailable?

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

Sidebar

Related Questions

Is it possible to use something like this wrapper with fluent configuration? http://jeffreypalermo.com/blog/use-this-nhibernate-wrapper-to-keep-your-repository-classes-simple/ If
Using NHibernate 1.x we encountered this error, suddently, during a nigthly job: 25/06/2012 22:50:59
I read this article where Ayende states NHibernate can (compared to EF 4): Collection
I have overridden the default NHibernate DefaultDeleteEventListener according to this source: http://nhibernate.info/blog/2008/09/06/soft-deletes.html so I
This is the basic example from hbm-style nhibernate. http://ayende.com/blog/2327/multi-table-entities-in-nhibernate public class Person { public
I was often directed to this blog site when I was researching on NHibernate
I am using NHibernate version 2.0.0.4000. In one of my queries I wanted to
Is there a way to achieve SQL like this with NHibernate ICriteria or QueryOver?
I have this nhibernate criteria: criteria.Add(Subqueries.PropertyIn(Id, DetachedCriteria.For<ReconItemReconSide>() .SetProjection(Projections.ProjectionList() .Add(Projections.GroupProperty(ReconItemFk)) .Add(Projections.Min(ReconciliationSideFk))) .Add(Expression.In(Projections.Property(ReconItemFk), items)) )); -which
I'm new to NHibernate... I have been following this NHibernate Tutorial from Gabriel Schenker

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.