什么是NHibernate的HasOne和参考之间的区别? [英] What are the differences between HasOne and References in nhibernate?

查看:282
本文介绍了什么是NHibernate的HasOne和参考之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

之间有什么 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.

这篇关于什么是NHibernate的HasOne和参考之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆