I have the following NHibernate code:
return NHibernateHelper.Session.QueryOver<SubProject>()
.Where
(
sp => sp.CompletedDate == null
&& sp.ImportanceFlag.FlagID != GlobalConstants.ImportanceFlagID_Blue
&& sp.Project.SalesStatus.StatusID != GlobalConstants.SalesStatusID_NotSet
&& sp.Project.ProjectID != Guid.Empty
)
.OrderBy(sp => sp.Project.Client.CompanyName).Asc
.ThenBy(sp => sp.Project.ProjectName).Asc
.ThenBy(sp => sp.SubProjectName).Asc
.List();
However when it gets executed, returns the following exception message:
could not resolve property: Project.CompletedDate of:
TaskManager.Framework.Model.SubProject
Do I have to use JoinQueryOver similar to this: Nhibernate Linq query to QueryOver
And if so, how do I join multiple objects from SubProject?
Thanks 🙂
Tim
you get that error message cause Subproject entity doesn’t load Project related entity.
Your statement should look something like this:
I am not sure about the relation between Project and Client but I guess a Project has always an associated Client and so it should a many-to-one with a fetch-join.
If you want to know more about joins and fetching I’ve replied to another user few weeks ago.
And here’s an interesting article about the same topic.