fNH をカスタム タイプにマップしようとしていますが、問題があります。
カスタムタイプへのインターフェースを介して、fNHにその値を割り当ててもらいたい。エンティティのカスタム型のインスタンスを保持するために nHibernate も必要です。プロパティにアクセスすると常にインスタンス化されます。インスタンスを上書きせず、ラップされた値を設定するだけです。
以下のマッピングを試すと、「クラス 'Entities.User のプロパティ 'Value' のゲッターが見つかりませんでした」という例外がスローされます
アイデア?
fNH マッピング:
Map(x =>((IBypassSecurity<string>)x.SecuredPinNumber).Value,"[PinNumber]");
ドメインの例:
public class User
{
public SecureField<string> SecuredPinNumber {get;private set;}
}
public class SecureField<T> : IBypassSecurity<T>
{
public T Value { get; set; } // would apply security rules, for 'normal' use
T IBypassSecurity<T>.Value {get;set;} // gets/sets the value directy, no security.
}
// allows nHibernate to assign the value without any security checks
public interface IBypassSecurity<T>
{
T Value {get;set;}
}