I'm trying to get fNH to map to a custom type, but I'm having difficulties.
I want fNH to assign its value, via an interface to the custom type. I also need nHibernate to preserve the instance of the custom type on the entity. It will always be instantiated when the property is accessed, don't overwrite the instance, just set the wrapped value.
When I try the below mapping, it throws an exception "Could not find a getter for property 'Value' in class 'Entities.User"
Ideas?
fNH mapping:
Map(x =>((IBypassSecurity<string>)x.SecuredPinNumber).Value,"[PinNumber]");
Domain example:
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;}
}