NHibernate: display one column twice

Is it possible to map one column twice using NHibernate?

<property name="CustomerID" index="IX_Customer" not-null="true" /> <many-to-one name="Customer" column="customerid" class="Customer" fetch="join" /> 

I need to have a raw identifier to bind a WinForms control that only supports binding, using a value (instead of the element itself).

  myControl.DataBindings.Add(new System.Windows.Forms.Binding("SelectedValue", bs, "CustomerID", true)); 
+4
source share
2 answers

Yes, just change

 <property name="CustomerID" index="IX_Customer" insert="false" update="false" not-null="true" /> 
+7
source

You can, but it's a really bad idea. see IndexOutOfRangeException Deep in the bowels of NHibernate

you must find another way to bind the identifier from the object to your control

0
source

Source: https://habr.com/ru/post/1393196/


All Articles