0
// load the client and any many to one relationships
var clientRootQuery = session.QueryOver(() => clientAlias);
clientRootQuery.Left.JoinAlias(() => clientAlias.Person,() => personAlias)
.Left.JoinAlias(() => personAlias.SexType,() => sexTypeAlias)
.Left.JoinAlias(() => personAlias.EyeColorType,() => eyeColorTypeAlias)
.Left.JoinAlias(() => clientAlias.Organization,() => organizationAlias)
.Left.JoinAlias(() => clientAlias.ClientStatusType,() => clientStatusTypeAlias)
.Left.JoinAlias(() => clientAlias.Notes,() => noteAlias)
.Left.JoinAlias(() => noteAlias.Comments,() => commentAlias)
.Where(() => clientAlias.Id == clientId)
.Future<Client>();
// load the note collection into the nhibernate session
// todo ******************** this doesn't work. nhibernate is still firing off queries in the adapter fill method rather than using the values pulled here.
var notes = session.QueryOver(() => clientAlias)
.Left.JoinAlias(() => clientAlias.Notes,() => noteAlias)
.Left.JoinAlias(() => noteAlias.Comments,() => commentAlias)
.Where(() => clientAlias.Id == clientId)
.Future<Client>();
return clientRootQuery.Take(1).SingleOrDefault();
這不會返回客戶端對象上的許多地址,也不會返回很多筆記。這應該工作。有許多筆記和許多地址的客戶。nHibernate多對多沒有獲取檢索對象上的子對象列表
任何想法?