i have spent hours trying to figure this out including going through all the previously asked questions on StackOverflow.
i am trying to query from the TrainingCourse by EvaluationHeadId, thats works fine, however, i try to get the TrainingRoute it returns "could not resolve property: TrainingRoute.TrainingRouteDefinition of: Model.Entities.TrainingCourse"
it saves perfect, my real problem is the query.
updated to:
using (var session = SessionProvider.Instance.OpenSession())
{
using (var transaction = session.BeginTransaction())
{
dto = session.QueryOver<TrainingCourse>()
.JoinQueryOver<EvaluationHead>(p => p.EvaluationHeads)
.JoinQueryOver<TrainingRoute>(p => p.TrainingRoute)
.Where(c => c.EvaluationHeadID == headId)
.SelectList(l => l
.Select(h => h.TrainingCourseDefn).WithAlias(() => d.TrainingCourseDefn)
.Select(h => h.IsAvailable).WithAlias(() => d.IsAvailable)
.Select(h => h.TrainingRoute.TrainingRouteDefinition).WithAlias(() => d.TrainingRouteDefinition))
.TransformUsing(Transformers.AliasToBean<TrainingCourseDTO>())
.List<TrainingCourseDTO>();
transaction.Commit();
}
}
Mappings:
public TrainingCourseMap()
{
Id(x => x.TrainingCourseID).GeneratedBy.Identity();
Map(x => x.TrainingCourseDefn);
Map(x => x.IsAvailable);
Map(x => x.TrainingCourseCreatedBy);
Map(x => x.TrainingCourseDtCreation);
Map(x => x.TrainingCourseDtModified);
Map(x => x.TrainingCourseModifiedBy);
References(x => x.TrainingRoute).Column("TrainingRouteID").Cascade.None();
HasManyToMany(x => x.EvaluationHeads).Table("EvaluationTraining").ParentKeyColumn("TrainingCourseID").ChildKeyColumn("EvaluationHeadID").Inverse().Cascade.All();
}
public EvaluationHeadMap()
{
Id(x => x.EvaluationHeadID).GeneratedBy.Identity();
Map(x => x.ManagerID);
Map(x => x.SupervisorID);
Map(x => x.EvaluationStartPeriod);
Map(x => x.EvaluationEndPeriod);
Map(x => x.EmployeeScalePoint);
Map(x => x.KRASignature);
Map(x => x.KRASignatureDate);
Map(x => x.DateCreated);
Map(x => x.DateModified);
HasMany(x => x.KeyResultAreas).KeyColumn("EvaluationHeadID").Cascade.All().Inverse();
HasMany(x => x.Evaluations).KeyColumn("EvaluationHeadID").Inverse().Cascade.All();
HasManyToMany(x => x.TrainingCourses).Table("EvaluationTraining").ParentKeyColumn("EvaluationHeadID").ChildKeyColumn("TrainingCourseID").Cascade.All().AsBag();
References(x => x.Stage).Column("StageID").Cascade.None();
References(x => x.Employee).Column("EmployeeID").Cascade.None();
References(x => x.Employment).Column("EmploymentID").Cascade.None();
//References(x => x.Manager).Column("EmployeeID");
//References(x => x.Supervisor).Column("EmployeeID");
}
public TrainingRouteMap()
{
Id(x => x.TrainingRouteID).GeneratedBy.Identity();
Map(x => x.TrainingRouteDefinition);
Map(x => x.TrainingRouteDescription);
HasMany(x => x.TrainingCourses).KeyColumn("TrainingRouteID").Cascade.AllDeleteOrphan().Inverse();
}
note: i have another query between TrainingCourse and TrainingRoute and it gives no issue at all, even accessing properties through TrainingCourse.TrainingRoute.x pattern. The only difference with this one is that am querying other tables as well.