流利的NHibernate&一到一个 [英] Fluent NHibernate & one-to-one

查看:129
本文介绍了流利的NHibernate&一到一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(很长一段时间)我一直在寻找一个关于如何用Fluent NHibernate正确实现一对一映射的例子。

我发现的大多数资源是:


我想你的意思是多对一


然而,没有人真正给出了如何正确实现一对一关系的例子。



<所以,你能给一个与Fluent NHibernate的一对一映射的例子吗?



注意:我不感兴趣的人说你的模型是什么,你可能实际上需要。不,谢谢,我只需要一个 one-to-one 示例。更准确地说,我知道语法 / strong>即可。这是我自己搜索的唯一的东西。我正在寻找的是一个更完整的例子,包括一个((非常)简单的)数据库设置,以及参与关系的所有实体的整个映射,我认为这对Stack Overflow来说是合理的。我已经解决了我的问题。

我也写了关于这个问题的详细的文章,你可以找到: http://brunoreis.com/tech/fluent-nhibernate-hasone-how-implement-one-to-one-relationship/index.html



您会发现我们需要一对一关系的场景,我们希望的数据库架构,需要满足NHibernate要求的模型代码,以及符合情况的 Fluent 映射。


For a (very) long time I've been looking for an example on how to correctly implement a one-to-one mapping with Fluent NHibernate.

Most resources I find say:

I think you mean a many-to-one

However no one actually gives an example on how to correctly implement the one-to-one relation.

So, could you give an one-to-one mapping example with Fluent NHibernate?

Note: I'm not interested in people saying "what's your model, you might actually need HasMany". No, thanks, I simply need a one-to-one example.

To be more precise, I know the syntax. That's the only thing I could find by searching by myself. What I'm looking for is a more complete example, including a ((very) simple) database setup, and the whole mapping, of all entities that participate in the relationship, which I think would have reasonable size for Stack Overflow.

解决方案

I've solved my problem.

I've also written a somewhat detailed article on this problem, that you can find at: http://brunoreis.com/tech/fluent-nhibernate-hasone-how-implement-one-to-one-relationship/index.html

You will find a scenario in which we want a one-to-one relationship, the database schema as we would like it, the code of the model as it needs to be to meet NHibernate requirements, and the Fluent mapping that corresponds to the situation.

这篇关于流利的NHibernate&amp;一到一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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