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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:39:18+00:00 2026-05-28T05:39:18+00:00

I have a table fill query, which have to get all references entities. I

  • 0

I have a table fill query, which have to get all references entities.

I have client:

public class Client 
{
    public virtual int Id { get; set; }
    public virtual ICollection<Address> Addresses { get; protected set; }
    public virtual Address CurrentAddress { get; set; }
}

Address

public class Address 
{
   public virtual int Id { get; set; }
   public virtual string Address1 { get; set; }      
   public virtual string City { get; set; }
   public virtual string ZipCode { get; set; }
}

and DB diagram:

enter image description here

I want get all users Addresses by Linq to Nhibernate:

ClientRepository.Where(x => x.Id == clientId).SelectMany(c => c.Addresses ).Where(x => x.Address1.Contains("Comp")).ToList();

But I got this query:

SELECT TOP (20 /* @p0 */) Id31_,
                 Address2_31_,
                 Address3_31_,
                 City31_,                
                 ZipCode31_
FROM   (select address2_.Id                                    as Id31_,
               address2_.Address1                              as Address2_31_,
               address2_.Address2                              as Address3_31_,
               address2_.City                                  as City31_,               
               address2_.ZipCode                               as ZipCode31_,
               ROW_NUMBER() OVER( ORDER BY address2_.Address1) as __hibernate_sort_row
        from   CLIENTS client0_
               inner join AddressToClient addresshis1_
                 on client0_.Id = addresshis1_.ClientId
               inner join ADDRESSES address2_
                 on addresshis1_.AddressId = address2_.Id
        where  address2_.Id = 2 /* @p1 */) as query
WHERE  query.__hibernate_sort_row > 0 /* @p2 */
ORDER  BY query.__hibernate_sort_row

EDITED
My repository:

/// <summary>
/// Gets the repository query.
/// </summary>
/// <value>The repository query.</value>
protected override IQueryable<Client> RepositoryQuery
{
   get
   {
     return Session.Query<Client>();
   }
}

Where query filters by id = address2_.Id not client id.

Why search appears by address Id not client?

  • 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-28T05:39:19+00:00Added an answer on May 28, 2026 at 5:39 am

    Try changing one of your two “x” variable names to something different. There is a bug in the current NHibernate release version that could cause this.

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

Sidebar

Related Questions

I have table which is filled from external application. I need to fill column
I have a query in understanding the SQLDataAdapter fill method,which takes arguments like startRecord,MaxRecord
I have a table that has multiple fields which I just need one field.
I'm calling some data from my Oracle table and I have a field which
Currently I have a DataGridView in my app which I fill from my Linq-to-SQL
I have a members only website in which the logged in users fill in
I have a ComboBox: <ComboBox Name=Gen2Fis ItemsSource={Binding Path=Table} SelectionChanged=Gen2Fis_SelectionChanged DisplayMemberPath=LongName> The query used to
In SQL Server 2008, I have a strongly typed data set with a table:
I have a large access table . I need to have a column which
I am triig to fill options list. I have 2 tables USERS and STREAMS

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.