Ahh bugger, I guess that other thread is one of the hundred or so "I'll get
back to it at some point" threads that I have starred in gmail. :(

On Thu, Dec 17, 2009 at 9:00 AM, Christian De Kievit <[email protected]>wrote:

> Rob,
>
> For starters, you should only specify Inverse() on one side of the
> relationship.  You need to figure out which side "owns" the relationship,
> and then use inverse() on the other side.  May not fix the problem, but
> you'll still need to do it.
>
> Cheers,
> Christian
>
> 2009/12/17 Rob Gibbens <[email protected]>
>
> I found this post, but I'm not sure if it was ever fixed.
>>
>>
>> http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/4612913df1a4d916/9b07e19ce9e0de9e?lnk=raot
>>
>>
>> On Dec 16, 3:16 pm, Rob Gibbens <[email protected]> wrote:
>> > Does anybody know how I would map an entity with two many-to-many
>> > collections of the same child type.
>> > My database structure is this....
>> > -----------------------------------------------------------------
>> > The "normal" relationship will be....
>> > tbl_Parent
>> >   col_Parent_ID
>> > tbl_Parent_Child_Xref
>> >    col_Parent_ID
>> >    col_Child_ID
>> > tbl_Child
>> >    col_Child_ID
>> > -----------------------------------------------------------------
>> > The alternative relationship is...
>> > tbl_Parent
>> >   col_Parent_ID
>> > tbl_Include_ParentChild_Xref
>> >    col_Parent_ID
>> >    col_Child_ID
>> > tbl_Child
>> >    col_Child_ID
>> > -----------------------------------------------------------------
>> > The entity and mapping look like this...
>> > public partial class ParentEntity : AuditableDataEntity<ParentEntity>
>> > {
>> >   public virtual IList<ChildEntity> Children { get; set; }
>> >   public virtual IList<ChildEntity> IncludedChildren { get; set; }
>> >
>> > }
>> >
>> > public partial class ParentMap : IAutoMappingOverride<ParentEntity>
>> > {
>> >         public void Override(AutoMapping<ParentEntity> mapping)
>> >         {
>> >                 mapping.Table("tbl_Parent");
>> >                 mapping.HasManyToMany(x => x.Children)
>> >                 .Table("tbl_Parent_Child_Xref")
>> >                 .ParentKeyColumn("col_Parent_ID")
>> >                 .ChildKeyColumn("col_Child_ID")
>> >                 .Inverse()
>> >                 .Cascade.All();
>> >                 mapping.HasManyToMany(x => x.IncludedChildren)
>> >                 .Table("tbl_Include_ParentChild_Xref")
>> >                 .ParentKeyColumn("col_Parent_ID")
>> >                 .ChildKeyColumn("col_Child_ID")
>> >                 .Inverse()
>> >                 .Cascade.All();
>> >         }
>> >
>> > }
>> >
>> >
>> ---------------------------------------------------------------------------
>> > ---------------------------
>> > The child entity and mapping look like this (just the opposite of the
>> > parent)...
>> >
>> > public partial class ChildEntity : AuditableDataEntity<ChildEntity>
>> > {
>> >   public virtual IList<ParentEntity> Parents { get; set; }
>> >   public virtual IList<ParentEntity> IncludedParents { get; set; }
>> >
>> > }
>> >
>> > public partial class ChildMap : IAutoMappingOverride<ChildEntity>
>> > {
>> >         public void Override(AutoMapping<ChildEntity> mapping)
>> >         {
>> >                 mapping.Table("tbl_Child");
>> >                 mapping.HasManyToMany(x => x.Parents)
>> >                 .Table("tbl_Parent_Child_Xref")
>> >                 .ParentKeyColumn("col_Child_ID")
>> >                 .ChildKeyColumn("col_Parent_ID")
>> >                 .Inverse()
>> >                 .Cascade.All();
>> >             mapping.HasManyToMany(x => x.IncludedParents)
>> >                 .Table("tbl_Include_ParentChild_Xref")
>> >                 .ParentKeyColumn("col_Child_ID")
>> >                 .ChildKeyColumn("col_Parent_ID")
>> >                 .Inverse()
>> >                 .Cascade.All();
>> >         }
>> >
>> > }
>> >
>> > -----------------------------------------------------------------
>> > The error that I'm getting is
>> > "System.NotSupportedException: Can't figure out what the other side
>> > of
>> > the many-to-many property 'Children' should be."
>> >
>> > I'm using NHibernate 2.1.2, FluentNhibernate 1.0.
>>
>> --
>>
>> 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]<fluent-nhibernate%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/fluent-nhibernate?hl=en.
>>
>>
>>
>
>
> --
> Christian De Kievit
>
> --
> 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]<fluent-nhibernate%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>

--

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