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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:24:23+00:00 2026-05-27T09:24:23+00:00

I have two entities: Client, and AccountPlan, that have a 1 to 0..1 relationship.

  • 0

I have two entities: Client, and AccountPlan, that have a 1 to 0..1 relationship. I would like to fetch my Clients, ordered first by Clients that have an AccountPlan, and then by Clients that do not. When I try the following Linq to Nhibernate query:

        return NHibernateSession.Current.Query<Client>()
            .Where(x => x.SalesRepId == id)
            .OrderBy(x => x.AccountPlan == null);

I get a QuerySyntaxException with the following message:

{“Exception of type ‘Antlr.Runtime.NoViableAltException’ was thrown.
[.OrderBy(.Where(NHibernate.Linq.NhQueryable`1[FIS.AccountManagement.Core.Domain.Client],
Quote((x, ) => (Equal(x.SalesRepId, p1))), ), Quote((x, ) =>
(Equal(x.AccountPlan, ))), )]”}

Here’s the mapping relationship between the two entities, if that’s important:

    public ClientMap()
    {
        HasOne(x => x.AccountPlan).PropertyRef(r => r.Client);
    }


    public AccountPlanMap()
    {
        DynamicInsert();

        References(x => x.Client, "EntityID");
    }

Does anyone know of a query from one of NHibernate’s myriad APIs that will accomplish what I want? Thanks in advance.

  • 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-27T09:24:24+00:00Added an answer on May 27, 2026 at 9:24 am

    two queries in one roundtrip concated together

    var clientsWithPlan = NHibernateSession.Current.Query<Client>()
        .Where(x => x.SalesRepId == id)
        .Where(x => x.AccountPlan != null)
        .Future();
    
    var clientsWithoutPlan = NHibernateSession.Current.Query<Client>()
        .Where(x => x.SalesRepId == id)
        .Where(x => x.AccountPlan == null)
        .Future();
    
    return clientsWithPlan.Concat(clientsWithoutPlan);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables/entities client and site that have a many to many relationship
I have two Core Data entities ( Client and UserFile ) that I have
I have two entities Visita and Cliente that implements respectively two interfaces IVisita and
I have two entities like this: public class Service { public virtual int ServiceId
I have two entities: Patient and Job. Patient has a to-many relationship to Job
i have two Entities, Parent and Child, that are linked through a bidirectional one-to-many
I have a Core Data stack in which there are two entities: 'Client' and
I have two tables in the clients mssql database. The first is a job
I have two entities: Article and Category. That have a many to many table:
I have two entities with many-to-many relationship defined on them. <set name=TreasuryCodes table=ServiceProviderAccountTreasuryCode lazy=true

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.