Many To One/Reference property as Discriminator

131 views
Skip to first unread message

Johnny Alibuyog

unread,
Jun 28, 2011, 5:01:17 AM6/28/11
to fluent-n...@googlegroups.com
Hi All,

Is there any possible way to use a mapped many-to-one property as discriminator.
My mapping looks like this

     Reference(x => x.BusinessType);
     DiscriminateSubClassesOnColumn("BusinessTypeId")
          .AlwaysSelectWithValue()
          .Length(3);

It generated the right table with the association but when saving, I encounter exception "Invalid Index 8 for this SqlParameterCollection with...".
I believe it is generating duplicate mapping for "BusinessTypeId".

Thank you in advance.

Best Regards,
Johnny

Trinition

unread,
Jul 18, 2012, 9:12:21 AM7/18/12
to fluent-n...@googlegroups.com
I'm having this same trouble.  Did you ever find a solution?  This StackOverflow post suggests using a formula: 
http://stackoverflow.com/questions/3426477/nhibernate-using-a-discriminator-column-as-a-many-to-one-relationship 

Trinition

unread,
Jul 18, 2012, 10:37:38 AM7/18/12
to fluent-n...@googlegroups.com
FWIW, that StackOverflow article solved it for me -- use a formula that is just the many-to-one's column,
Reply all
Reply to author
Forward
0 new messages