Additional fields in NHibernate many-to-many relationship tables

when I have a many-to.many relationship with nhibernate and let nhibernate generate my db schema, it adds an extra table that contains the primary keys of the related objects. is it possible to add additional fields to this and access them without having to manually process sql?

+3
source share
3 answers

I do not think that's possible. If you say that the relation has some kind of state than in essence, it is an object in its own right and should be considered (displayed) as such.

+6
source

. , , - , , 1-N N-1 .

, NHibernate , , .

0

In this case, how would you build a new object in the map file (which acts as a bridge between the two initial tables)? In my case, this link table has two foreign keys (int), one for each initial table, and also some other fields (startDate, endDate)

The thing is, in my new object, I have no properties for these two foreign keys. I have only one property that relates to the type of object that the foreign key points to.

0
source

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


All Articles