简体   繁体   中英

Generic Lookup table using fluent nhibernate

I can't figure out how to map a table structure like below within fluent nhibernate. 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. The id goes directly to the CodeValue table. So inside code you will find hardcoded values for the CodeSet tables. This is old code and I don't know if I should just change it or if nHibernate can deal with it.

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.

So the data would look like:

CodeSetId Name Display

  • 1 "TransactionType" "Transaction Type"
  • 2 "MemberType" "Member Type"

CodeValueId CodeSetId Name Display ReferenceValue

  • 1 1 ER Visit ER Visit 100
  • 2 1 Surgery Surgery 200
  • 3 2 Doctor Doctor 500
  • 4 2 Patient Patient 600

TransactionId TransactionTypeId Name

  • 1 1 Some ER Transaction
  • 2 2 Some Surgery Transaction

MemberId FirstName LastName MemberTypeId

  • 1 Betty Boo (Doctor) 3
  • 2 Sammy Sue (Patient) 4

I suggest you read or walkthrough the 'Your first project' in the Fluent NHibernate 'Getting Started' document.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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