I'm trying to create a query using NHibernate and searching along multiple foreign keys:
The following code works when I'm only searching on one of the foreign keys:
ICriteria query = Session.CreateCriteria<TblTeam>()
.Add<TblTeam>(x => x.FldUrlSafeName == teamName)
.CreateCriteria<TblTeam>(x => x.TblSportsType)
.Add<TblSportsType>(x => x.FldUrlSafeName == sportsType);
return query.UniqueResult<TblTeam>();
I need to search on two of the foreign keys so I created the following:
ICriteria query = Session.CreateCriteria<TblTeam>()
.Add<TblTeam>(x => x.FldUrlSafeName == teamName)
.CreateCriteria<TblTeam>(x => x.TblSportsType)
.Add<TblSportsType>(x => x.FldUrlSafeName == sportsType)
.CreateCriteria<TblTeam>(x => x.TblSportsOrganization)
.Add<TblSportsOrganization>(x => x.FldUrlSafeName == sportsOrganization);
return query.UniqueResult<TblTeam>();
Unfortunately, this gives me the following error:
"could not resolve property: TblSportsOrganization of: site.Core.TblSportsType"
How would I have it take a "step back" as it were so I can add criteria to TblTeam and not TblSportsType?