简体   繁体   English

使用流利的NHibernate的通用查找表

[英]Generic Lookup table using fluent nhibernate

I can't figure out how to map a table structure like below within fluent nhibernate. 我无法弄清楚如何在流畅的hhibernate中映射如下表结构。 Based on how I have the data laid about below you can see that there is no direct relationship between the Transaction or Member table and the CodeSet table. 根据我下面的数据放置方式,您可以看到Transaction或Member表与CodeSet表之间没有直接关系。 The id goes directly to the CodeValue table. 该ID直接进入CodeValue表。 So inside code you will find hardcoded values for the CodeSet tables. 因此,在内部代码中,您将找到CodeSet表的硬编码值。 This is old code and I don't know if I should just change it or if nHibernate can deal with it. 这是旧的代码,我不知道是否应该更改它或nHibernate是否可以处理它。

I have the following tables: 我有以下表格:

Generic Lookup tables: 通用查询表:

CodeSet 代码集

    ID
    Name
    Display

CodeValue 代码值

    ID
    CodeSetId
    Name
    Display
    ReferenceValue

I then have tables like 然后我有像

Transaction 交易

    ID
    TransactionTypeId
    Name

Member 会员

    ID
    FirstName
    LastName
    MemberTypeId 

The TransactionTypeId and MemberTypeId relates back to the CodeValueId on the CodeValue table. TransactionTypeIdMemberTypeId与CodeValue表上的CodeValueId相关。

So the data would look like: 因此数据如下所示:

CodeSetId Name Display CodeSetId名称显示

  • 1 "TransactionType" "Transaction Type" 1“交易类型”“交易类型”
  • 2 "MemberType" "Member Type" 2“会员类型”“会员类型”

CodeValueId CodeSetId Name Display ReferenceValue CodeValueId CodeSetId名称显示ReferenceValue

  • 1 1 ER Visit ER Visit 100 1 1 ER访问ER访问100
  • 2 1 Surgery Surgery 200 2 1手术手术200
  • 3 2 Doctor Doctor 500 3 2医生Doctor 500
  • 4 2 Patient Patient 600 4 2患者患者600

TransactionId TransactionTypeId Name TransactionId TransactionTypeId名称

  • 1 1 Some ER Transaction 1 1一些ER交易
  • 2 2 Some Surgery Transaction 2 2一些外科手术

MemberId FirstName LastName MemberTypeId MemberId FirstName LastName MemberTypeId

  • 1 Betty Boo (Doctor) 3 1贝蒂·布(医生)3
  • 2 Sammy Sue (Patient) 4 2 Sammy Sue(患者)4

I suggest you read or walkthrough the 'Your first project' in the Fluent NHibernate 'Getting Started' document. 我建议您阅读或浏览Fluent NHibernate“入门”文档中的“您的第一个项目”。

The retail company example has a very similar structure to what you're trying to implement. 零售公司示例的结构与您要实现的结构非常相似。

https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started https://github.com/jagregory/fluent-nhibernate/wiki/入门

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM