2010-12-10 3 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. NHibernate에는 기본 데이터베이스 유형으로 직접 번역 할 수있을 것입니다 경우

예는 사전에 오브젝트 유형이 재미있을 수 매핑

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

수 있습니다, 난 모르겠어요.

관련 문제