<class name="Customer,DomainModel" table="Customer">
<id name="CustomerId" column="CustomerId" type="Int32" unsaved-value="0">
<generator class="native"></generator>
</id>
<property name="Firstname" column="Firstname" type="string" length="50" not-null="false"></property>
<property name="Lastname" column="Lastname" type="string" length="50" not-null="false"></property>
<bag name="Orders" table="[Order]" generic="true" inverse ="false" cascade ="All" >
<key column="Customer"/>
<!--这里面 one-to-many 和 composite-element都能实现一对多,他们之间有什么区别-->
<one-to-many class="DomainModel.Entities.Order,DomainModel" />
<!--composite-element class="DomainModel.Entities.Order,DomainModel">
<parent name="Customer"/>
<property name="OrderId" column="OrderId" type="Int32"/>
<property name="OrderDate" column ="OrderDate" type="DateTime" not-null="false"/>
</composite-element-->
</bag>
</class>one-to-many 和 composite-element都能实现一对多,他们之间有什么区别
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
3条回答 默认 最新
AngelAndAngel 2011-10-12 17:25关注前者更多的是表现关联关系,后者更多的是表现从属关系
有很多需求这种都可以实现,只是说体现不同的想法了。
比如说一个人有很多邮箱,那么这个邮箱就是从属于这个人,那么同样,你仍然可以认为,这两种是关联关系而已。本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报