2012-03-07 5 views
0

"Id、TypeId、Value"というすべての辞書には1つのテーブルがあります。特定のTypeIdにはペアがあります。具体的な辞書は "Id + Value"です。NHibernateの汎用辞書テーブルマッピング

どのようにマップする必要がありますか? InvoiceTypeDictionary、PaymentTypeDictionaryなど(私はTYPEIDするサブクラス弁別器を設定することができ、それはそれだ):私は抽象クラス辞書を持っており、具体的なクラスだろうと想像することができる瞬間

。しかし、必要な多くのサブクラスを避けるために、別の方法がありますか?

答えて

0

どのような価値があるのか​​わかりません。

// InvoiceTypeMap : ClassMap<InvoiceType> 
public InvoiceTypeMap() 
{ 
    Table("dictionaryTable"); 
    Where("typeid=5"); 
    Map(it => it.SomeProperty, "value"); 
} 

// PaymentTypeMap : ClassMap<PaymentType> 
public PaymentTypeMap() 
{ 
    Table("dictionaryTable"); 
    Where("typeid=3"); 
    Map(it => it.SomeOtherProperty, "value"); 
} 


void SetInvoiceTypeToEntity(Invoice invoice, int invoicetypeid) 
{ 
    invoice.Invoicetype = session.Get<InvoiceType>(invoicetypeid); 
    // or when you only need the Reference without the actual object here 
    invoice.Invoicetype = session.Load<InvoiceType>(invoicetypeid); 
} 
関連する問題