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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:07:46+00:00 2026-05-25T03:07:46+00:00

Hi i have a problem with mapping in Nhibernate. When I run a linq

  • 0

Hi i have a problem with mapping in Nhibernate. When I run a linq query referring to one of the component classes of my entity, I get a QueryException as below:

could not resolve property: ClosedCases of: Project.Entities.Headline

I have one table with records which i want to map into multiple objects of my headline entity.

Question:

Is there something wrongly set up in my mapping?

My Headline entity is separated into multiple logical classes as you can see below

  public class Headline:Entity
  {
    public virtual DateTime Date { get; set; }
    public virtual TeamTarget Teamtarget { get; set; }
  } 

 public class TeamTarget : Entity
  {
    public virtual DateTime FromDate { get; set; }
    public virtual DateTime ToDate { get; set; }
    public virtual TargetItem AchievedTarget { get; set; }
    public virtual Team Team { get; set; }
    }  

public class TargetItem : Entity
  {
    public virtual decimal ClosedCases { get; set; }
    public virtual decimal Invoicing { get; set; }
  }

Mapping file:

  public class HeadlineMap: ClassMap<Headline>
  {
    public HeadlineMap()
    {
      Table("Headlines.Headlines");
      Id(x => x.Id).Column("HeadlinesId");
      Map(x => x.Date);
      Component(x => x.Teamtarget, t =>
      {
        t.References(x => x.Team).Column("TeamId").Cascade.None();
        t.Component(x => x.AchievedTarget, ti =>
        {
          ti.Map(x => x.Invoicing).Column("TeamInvoicing");
          ti.Map(x => x.ClosedCases).Column("TeamClosedCases");
        });
      });

The Linq query I am running looks like this:

decimal closedCases = _headlineRepository.All
.Where(x =>
x.Date >= DateTimeExtensionMethods.FirstDayOfMonthFromDateTime(selectMonthFromDate)
&& x.Date <= DateTimeExtensionMethods.LastDayOfMonthFromDateTime(selectMonthFromDate)
&& x.Teamtarget.Team.Id == teamId
).Average(x => x.Teamtarget.AchievedTarget.ClosedCases);

I know that i can access headline item by using team entity by team id and this works, just have problem with the mapping of achieved target.
any ideas?

  • 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-25T03:07:47+00:00Added an answer on May 25, 2026 at 3:07 am

    I think your mapping is fine. But as far as I know, it isn’t possible to query a nested component with Linq to NHibernate. It can’t understand what joins to do, it becomes too complex.

    I think it is possible using NHibernate 3’s QueryOver API using JoinQueryOver or JoinAlias. You should read this: QueryOver in NH 3.0

    Maybe something like this would work:

    Headline headlineAlias = null;
    TeamTarget targetAlias = null;
    Team teamAlias = null;
    TargetItem targetItemAlias = null;
    
    var query = session.QueryOver<Headline>(() => headlineAlias)
                       .JoinAlias(() => headlineAlias.Teamtarget, () => targetAlias)
                       .JoinAlias(() => targetAlias.Team, () => teamAlias)
                       .JoinAlias(() => targetAlias.AchievedTarget, () => targetItemAlias)
                       .Where(x => x.Date >= DateTimeExtensionMethods.FirstDayOfMonthFromDateTime(selectMonthFromDate) && x.Date <= DateTimeExtensionMethods.LastDayOfMonthFromDateTime(selectMonthFromDate))
                       .And(() => teamAlias.Id == teamId)
                       .Select(Projections.Avg(() => targetItemAlias.ClosedCases))
                       .SingleOrDefault<decimal>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just started using Fluent NHibernate and have run into the following problem trying
I have a problem with the mapping of Oracle Float double precision datatype to
I have a problem which requires a reversable 1:1 mapping of keys to values.
I have problem with fancybox. I want to write a function that will run
I have been trying to implement Nhibernate.Linq 1.0.0.4000 together with Nhibernate 2.1.2.4000. After what
I just had a NHibernate related problem where I forgot to map one property
I have a problem with nhibernate when I try to insert an object with
I have a problem getting my change(s) to data object retrieved using NHibernate to
I have a problem mapping an Id. The structures of the entities are as
I have an NHibernate problem with lists, which are mapped as subclasses of an

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.