// 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();
这不会返回客户端对象上的许多地址,也不会返回许多注释。这应该有效。有一个客户有很多笔记和很多地址。
有任何想法吗?