2010-12-10 16 views
1

どのように私は私が直接あなたのインデクサーをマッピングする方法はないと思うが、あなたは公開することができます流暢なマッピングインデクサマッピングと流暢NHibernateはクラス

public class AttributeSet : DictionaryBase 
{ 
    private readonly Dictionary<string, object> _cache; 

    public AttributeSet() 
    { 
     _cache = new Dictionary<string, object>(); 
    } 

    public object this[string index] 
    { 
     get 
     { 
      return _cache[index]; 
     } 
     set 
     { 
      _cache[index] = value; 
     } 
    } 
} 



public class Entity 
{ 
    protected Entity() 
    { 
     Attributes = new AttributeSet(); 
    } 

    public virtual int Id { get; set; } 
    public virtual string Label { get; set; } 
    public virtual string Description { get; set; } 
    public virtual DateTime CreatedDate { get; set; } 

    public virtual AttributeSet Attributes { get; set; } 
} 

答えて

1

を使用して流暢NHibernateの持つクラス属性セットをマッピングすることができます基本的な辞書型とその代わりにそれをマップします。

辞書をパブリックとして公開しない場合は、プライベートプロパティとして代わりにexplained hereとして割り当てることができます。辞書をマッピングする場合は、see here

の例では、辞書内のオブジェクト型は面白いかもしれません

HasMany<object>(Reveal.Member<AttributeSet>("Cache")) 
    .KeyColumn("AttributeSetId") 
    .AsMap<string>(idx => idx.Column("Index"), elem => elem.Column("Value")) 
    .Access.CamelCaseField(Prefix.Underscore) 

マッピングされる可能性がありますNHibernateのは、基礎となるデータベースの種類に直接それを翻訳することができます場合、私は知りません。