NHibernate中的三向多对多映射 [英] Three-Way Many To Many Mapping in NHibernate

查看:68
本文介绍了NHibernate中的三向多对多映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在研究 NHibernate 时经常被引导到这个博客站点,很多时候我都得到了答案.我今天有一个问题.感谢您的帮助.

I was often directed to this blog site when I was researching on NHibernate and a lot of times I got my answers. I have a question today. I appreciate any assistance.

我现在面临的是:我们数据库中的一个简单映射表具有三个表的外键引用.三个参考表是:State、Organization 和 InsuranceProgram.三张表的结构为:

What I am facing now is this: a simple mapping table in our database has foreign key references to three tables. The three referenced tables are: State, Organization and InsuranceProgram. The structures of the three tables are:

状态

 1. StateId PK
 2. List item

StateShortName

StateShortName

组织

 1. OrgId PK
 2. OrgName

保险计划

 1. ProgId PK
 2. ProgramNam

映射表结构如下:

国家组织计划

 1. RecId PK 
 2. StateId FK 
 3. ProgId FK 
 4. OrgId FK

我知道如何并且确实映射了两个表之间的多对多关系,例如典型的产品和订单类型,但不确定映射我所谓的三对多关系"的最佳方法是什么.

I know how to and did map many to many relations between TWO tables such as the typical Products and Orders kind but not sure what is the best way to map what I call the "three-way many to many relationship".

希望我的问题简单明了,如果没有,请告诉我.

Hope I have made my question simple and clear but please let me know if not.

我做了很多谷歌搜索,但没有得到任何相关信息.非常感谢任何帮助!

I did quite some googling but didn't get anything related. Any help is greatly appreciated!

约翰

推荐答案

不再是多对多.您的 StateOrgProgram 现在实际上需要映射为一个实体,每个对象都与它有一对多的关系.

It's not a many-to-many any more. Your StateOrgProgram now actually needs to be mapped as an entity in its own right, with each object having a one-to-many relationship to it.

这篇关于NHibernate中的三向多对多映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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