// 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();
これは、クライアント オブジェクトで多くのアドレスを返すことも、多くのメモを返すこともありません。これはうまくいくはずです。多くのメモと多くのアドレスを持つクライアントがいます。
何か案は?