Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
NHibernate通用字典表映射_Nhibernate_Nhibernate Mapping - Fatal编程技术网

NHibernate通用字典表映射

NHibernate通用字典表映射,nhibernate,nhibernate-mapping,Nhibernate,Nhibernate Mapping,我的所有字典都有一个表:“Id,TypeId,Value”,所以对于特定的TypeId,我有一对:“Id+Value”,这是我的具体字典 我应该如何绘制地图 目前,我可以想象我将拥有一个抽象类字典和具体类:InvoiceTypeDictionary、PaymentTypeDictionary等(我可以将子类鉴别器设置为TypeId,就这样)。但是,有没有其他方法来避免必要的大量子类呢?我不确定值是什么 // InvoiceTypeMap : ClassMap<InvoiceType>

我的所有字典都有一个表:“Id,TypeId,Value”,所以对于特定的TypeId,我有一对:“Id+Value”,这是我的具体字典

我应该如何绘制地图


目前,我可以想象我将拥有一个抽象类字典和具体类:InvoiceTypeDictionary、PaymentTypeDictionary等(我可以将子类鉴别器设置为TypeId,就这样)。但是,有没有其他方法来避免必要的大量子类呢?

我不确定值是什么

// 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);
}
//InvoiceTypeMap:ClassMap
公共发票类型映射()
{
表(“字典表”);
其中(“typeid=5”);
Map(it=>it.SomeProperty,“value”);
}
//PaymentTypeMap:ClassMap
公共支付类型映射()
{
表(“字典表”);
其中(“typeid=3”);
Map(it=>it.SomeOtherProperty,“value”);
}
作废SetInvoiceTypeToEntity(发票发票,int invoicetypeid)
{
invoice.Invoicetype=session.Get(invoicetypeid);
//或者只需要引用而不需要实际对象
invoice.Invoicetype=session.Load(invoicetypeid);
}