什么是NHibernate的HasOne和参考之间的区别?区别、NHibernate、HasOne

2023-09-03 05:35:50 作者:曾经王者

之间有什么 HasOne的差异()引用()在NHibernate的?

What are the differences between HasOne() and References() in nhibernate?

推荐答案

HasOne 创建表你们之间的一个一对一的映射。 引用创建一个典型的关系多到一的关系。

HasOne creates a one-to-one mapping between tables for you. References creates a typical relational many-to-one relationship.

更多定义的:

一对一关系意味着,当一个记录存在于一个表,它必须(或可以)具有在其它引用的表1和至多一个记录。 例:的用户表,选项表(一个用户有一组固定的选项) 一个多对1关系意味着当一个记录存在于一个表,它可以具有在另一表中的多个相关记录。 例如:的用户表和购买表(一个用户可以做很多购买) a one-to-one relationship means that when one record exists in one table, it must (or can) have one and at most one record in the other referenced table. Example: User table and Options table (one user has one fixed set of options) a many-to-one relationship means that when one records exists in one table, it can have many related records in another table. Example: User table and Purchase table (one user can do many purchases).

注意:的,我说的的表的,你可以放心地替换成的类或实体的,如你所愿,使用FluentNH时,可以很容易地使用它们互换。

Note: where I say table you can replace that safely with class or entity as you wish, when using FluentNH it's easy to use them interchangeably.

这是更$ P $在这个fluentnhibernate维基文章 pcisely解释说。

This is more precisely explained in this fluentnhibernate wiki article.

 
精彩推荐
图片推荐