On Wed, Jan 6, 2016 at 10:45 AM, Michael Powell <mwpowell...@gmail.com> wrote: > Hello, > > I've got a situation where I'd like to reference some children from > the parent, but the children can reference potentially multiple > parents. That's by design. > > Allow me to explain: > > class Parent > { > public virtual IList<Child> Children { get; set; } > } > > class Child > { > public virtual Parent HusbandAndFather { get; set; } > public virtual Parent WifeAndMother { get; set; } > } > > In my Child mappings, references are allowed to get broken in the > Nullable, but not too broken, there should always be the zero, one, or > two references, all told, in the prescribed manner: > > References(x => x.HusbandAndFather, @"HusbandAndFatherId") > .LazyLoad() > .Nullable(); > > References(x => x.WifeAndMother, @"WifeAndMotherId") > .LazyLoad() > .Nullable(); > > In my Parent mappings: > > HasMany(x => x.Situations) > .LazyLoad() > .Inverse() > .AsBag() > .Cascade.AllDeleteOrphan(); > > I don't know if the Husband/Wife relationships are automatically > figured, or I need to further constraint in a .Where(), not even sure > how I would do that in Fluent-isms? > > It's one thing there is a "simple" parent/child collection > relationship going on, but how is this handled?
I am chewing on the thought of normalizing "Offspring" to capture what is essentially a many-to-many relationship. Although, I really don't want to encourage "polyamory", or that the tree should be a "graph". In my use case that seems most appropriate in cooperation with the ORM / data layers. With the stipulation that the model basically handle the heavy lifting enforcing the two references. This seems the most appropriate tradeoff from a database normalization perspective. class Offspring { public virtual Parent Parent { get; set; } public virtual Child Child { get; set; } // Order establishing "head" of the offspring relationships: i.e. to Husband/Father public virtual int Order { get; set; } } > Thank you... Still, if there are any thoughts, would be happy to consider them. Thank you... > Regards, > > Michael Powell -- You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To unsubscribe from this group and stop receiving emails from it, send an email to fluent-nhibernate+unsubscr...@googlegroups.com. To post to this group, send email to fluent-nhibernate@googlegroups.com. Visit this group at https://groups.google.com/group/fluent-nhibernate. For more options, visit https://groups.google.com/d/optout.