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

  • Home
  • SEARCH
  • 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 8721029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:09:23+00:00 2026-06-13T07:09:23+00:00

I have a problem with NHibenate. When I run queryover, I get an error

  • 0

I have a problem with NHibenate. When I run queryover, I get an error “could not resolve property: User.Name of: MegaOnlineChat.Core.Entities.Message”.What am I doing wrong?

Entity objects

public class EntityObject<TId>
    {
        public virtual Int32 Id { get; set; }
    }
public class User:EntityObject<Int32>
    {
        public virtual String Name { get; set; }
        public virtual String Password { get; set; }
        public virtual Boolean Admin { get; set; }
        public virtual IList<Message> Messages { get; set; }
    }
public class Message:EntityObject<Int32>
    {
        public virtual String Text { get; set; }
        public virtual User User { get; set; }
        public virtual DateTime Date{ get; set; }
    }

Mapping

public class UserMapping:ClassMap<User>
{
    public UserMapping()
    {
        Table("Users");
        Id(m => m.Id).GeneratedBy.Native();
        Map(m => m.Name).Unique().Not.Nullable();
        Map(m => m.Admin).Not.Nullable();
        Map(m => m.Password).Not.Nullable();

        HasMany(m => m.Messages).KeyColumn("User_id");
    }
}
public class MessageMapping:ClassMap<Message>
{
    public MessageMapping()
    {
        Table("Messages");

        Id(m => m.Id).GeneratedBy.Native();

        Map(m => m.Text).Not.Nullable();
        Map(m => m.Date).Not.Nullable();

        References(m => m.User, "User_id").Not.Nullable();
    }
}

QueryOver

NHibernateSession.QueryOver<Message>().Where(x => x.User.Name == name).List<Message>().Last();
  • 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-06-13T07:09:24+00:00Added an answer on June 13, 2026 at 7:09 am

    QueryOver is not the same as the Linq query provider. It would be easier to do:

    NHibernateSession.Query<Message>().Where(x => x.User.Name == name).ToList();
    

    But if you want to use QueryOver, you will need to explicitly join the relationships you want to navigate:

    NHibernateSession.QueryOver<Message>()
        .JoinQueryOver(x => x.User) // navigate to the user on the relationship
        .Where(u => u.Name == name) // this restriction is on the User now
        .List();
    

    you could also do this using an alias for user

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

Sidebar

Related Questions

I have a problem with: NHibernate.Cfg.Configuration.SetProperties() Not accepting the IDictionary: NHibernateConfigHandler I get the
Problem: SQLite assembly referenced in my DAL assembly does not get copied to the
I've just started using Fluent NHibernate and have run into the following problem trying
I've run into what could be a potential problem with the professor getting a
I have just run into quite surprising problem. The case is simple: return all
Iam have run into a little problem with a partial projection. I have an
Hi i have a problem with mapping in Nhibernate. When I run a linq
I have a problem with nhibernate mapping. I use the nhibernate 3.2 mapping by
I have a problem using Linq to NHibernate to load an object and eagerly
I query my NHibernate datasources using a Linq Expression. The problem I have with

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.