2011-11-01 68 views
1

转换功能NHibernate动态属性映射到NH 3.2映射我在功能NHibernate下面的映射:你如何通过代码相当于

public CustomFieldsMap() 
{ 
    Schema("schema"); 
    Table("table"); 

    Id(x => x.Id, m => m.Column("id")); 
    DynamicComponent(x => x.Fields, c => 
    { 
     ...insert code here... 
    }); 
} 

也能正常工作(与真正的代码中很明显)。

我在nHibernate 3.2中引入的代码特性映射中的等价物是什么(如果还有一个)?

回答

0

你不能使用RegisterDynamicComponentMapping?

2

您必须提供动态组件模板。

Component(x => x.Fields, new 
{ 
    IntField = 0, 
    RelationField = default(Related) 
}, dc => 
{ 
    // dynamic component members mappings 
    dc.Property(x => x.IntField); 
    dc.ManyToOne(x => x.RelationField); 
    // etc. 
}); 

查看this article的例子和解释。