如何使用自定义词典类的DynamicComponent映射

问题描述:

我喜欢使用自定义的IDictionary类我DynamicComponent映射:如何使用自定义词典类的DynamicComponent映射

class ObservableDictionary : Hashtable, INotifyCollectionChanged, INotifyPropertyChanged 

映射列表时有可能按如下方式使用自定义集合类型:

mapping.HasMany(x => x.Items).CollectionType<ObservableCollection<ItemClass>>(); 

但我怎么能用DynamicComponents做到这一点?没有CollectionType方法。

mapping.DynamicComponent(
    x => x.DynamicFields, 
    c => { 
      c.Map(x => x["fld_num"]).CustomType(typeof(int)); 
      c.Map(x => x["shortdesc"]).CustomType(typeof(string)); 
     }); 

如果您的自定义词典的内辞典保持数据,那么你可以

mapping.Component(x => x.DynamicFields, c => c.DynamicComponent(
    Reveal.Member<CustomDictionary, IDictionary>("_innerDictionary"), 
    c => { 
     c.Map(x => x["fld_num"]).CustomType(typeof(int)); 
     c.Map(x => x["shortdesc"]).CustomType(typeof(string)); 
    }) 
);