I think I might have a solution actually but I'll ask on nhibernate's
list anyway. Thanks for replying

On Aug 3, 10:15 pm, Paul Batum <[email protected]> wrote:
> Since this is a question about mapping complex hierarchies and is not about
> fluent nhibernate's behavior per se, I suggest you also ask on the
> nhibernate mailing list.
>
> On Mon, Aug 3, 2009 at 6:23 PM, JamesSpibey <[email protected]> wrote:
>
> > Hi,
>
> > I'm trying to map quite a complex hierarchy and I was hoping someone
> > here might be able to give me some guidance? I've tried to represent
> > it below but note that I am not using the real class names to make it
> > clearer.
>
> > Class Grandparent
> >  Property Parents As IList(Of Parent)
> > End Class
>
> > Class Parent
> >  Property Children As IList(Of Child)
> >  Property Parent As GrandParent
> > End Class
>
> > Class MustInherit Child
> >  Property GrandParent As GrandParent
> >  Property Parent As Parent
> > End Class
>
> > Class Boy
> >  Inherits Child
> > End Class
>
> > Class Girl
> >  Inherits Child
> > End Class
>
> > OK, simple enough. This is mapped successfully using FNH, with the
> > only complexity being that Boy and Girl are mapped using
> > DiscriminateSubClassesOnColumn.
>
> > Having done all that, I now need to do something like the following
>
> > Class SpecialGrandparent
> >  Inherits Grandparent
> >  Public Property AdditionalInfo As String
> > End Class
>
> > Class SpecialParent
> >  Inherits Parent
> >  Public Property AdditionalInfo As String
> > End Class
>
> > Class SpecialChild
> >  Inherits Child
> >  Public Property AdditionalInfo As String
> > End Class
>
> > The complexity comes from the fact that I need the SpecialGrandParent
> > to look and behave like a normal GrandParent class, but also be able
> > to access the 'AdditionalInfo' when needed.
>
> > So, I thought I'd solved this, and this is how I did it. (I'll just
> > show the example for one class but you'll get the idea)
>
> > Public Interface IGrandParent
> >  Property Parents  As IList(Of IParent)
> > End Interface
>
> > Class Grandparent
> >  Implements IGrandParent
> >  Property Parents  As IList(Of IParent) Implements
> > IGrandParent.Parents
> > End Class
>
> > Class SpecialGrandparent
> >  Implements IGrandParent
>
> >  Private _innerGrandParent As IGrandParent = New GrandParent
>
> >  Property Parents  As IList(Of IParent) Implements
> > IGrandParent.Parents
> >    Return _innerGrandParent.Parents
> >  End Property
>
> >  Public Property AdditionalInfo As String
> > End Class
>
> > This all works great but when I come to the mapping, I can't figure
> > out what's best to do. The way I have it now is that the
> > _innerGrandParent property is exposed as a public Property which I can
> > then map using map.References(). This ensures that the
> > _innerGrandParent field gets populated ok which is then used to proxy
> > all the fields in the interface.
>
> > However, if I then write a query which uses SpecialGrandParent.Parents
> > for example, I get an error because the Parents property hasn't been
> > explicitly mapped (it's being proxied from the _innerGrandParent
> > field).
>
> > Sorry for the long post but I'm so close to having this work, but yet
> > so far!
>
> > Thanks
>
> > James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to