简体   繁体   中英

Fluent nHibernate one-to-many equivalent

I'm moving from nhibernate hbm configuration to Fluent nHibernate. I am mapping a section of the hbm file

<bag name="ProgramsList" cascade="all-delete-orphan" inverse="true" lazy="false">
 <key>
  <column name="ProgramId" />
 </key>
 <one-to-many class="Program" />
</bag>

What I have mapped this in fluent api is as follows:

HasMany(x=>x.ProgramsList).AsBag().Cascade.AllDeleteOrphan().Inverse()
.KeyColumns.Add("ProgramId")

However, I doubt if I have got this correct, because the last <one-to-many> does not figure into it at all. How to do you specify that section of the configuration fluently?

You do not need to specify one-to-many . This will be folow the Inverse and KeyColumns on the another side of relation. It know the type if Program because it is a generic type in the ProgramsList collections.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM