如何以编程方式为Component添加自定义tuplizer?

时间:2011-12-03 05:23:02

标签: c# .net nhibernate nhibernate-mapping tuplizer

任何人都可以给我一些指导,如何以编程方式为Component添加自定义tuplizer?

将它添加到类中就像:

new Configuration().ClassMappings
                   .First()
                   .AddTuplizer(EntityMode.Map, "tuplizerClassName");

但是你如何为组件做同样的事情呢?

1 个答案:

答案 0 :(得分:2)

config.ClassMappings
    .SelectMany(cm => cm.PropertyIterator)
    .Where(prop => prop.IsComposite)
    .Select(prop => prop.Value)
    .Cast<NHibernate.Mapping.Component>()
    .ForEach(c => c.TuplizerMap[NHibernate.EntityMode.Map] = "tuplizerClassName");