Hi, I have a display problem in Nhibernate. When I run a linq query, referencing one of the component classes of my object, I get a QueryException, as shown below:
Failed to resolve property: ClosedCases of: Project.Entities.Headline
I have one table with records that I want to map to several objects of my header object.
Question:
Is something incorrectly configured in my mapping?
My Headline object is divided into several 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"); }); });
My Linq query 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 the header element using the command object by the command identifier, and this works, just a problem with displaying the achieved goal. any ideas?
source share