Sorry, I didn't realise that the custom types are tied against the mappings, not the domain model. I managed to put together the following class which maps ENUM('1','0') values to System.Boolean values, which I've put here in case anyone wants it (note: it hasn't been thoroughly tested).
Code:
public class EnumBooleanType : IUserType
{
private static NullableType m_stringType = NHibernateUtil.AnsiString;
private static string TrueValue = "1";
private static string FalseValue = "0";
public EnumBooleanType()
{
}
public new bool Equals(object x, object y)
{
return (x == y);
}
public SqlType[] SqlTypes
{
get
{
return new SqlType[] { m_stringType.SqlType };
}
}
public object DeepCopy(object value)
{
return value;
}
public void NullSafeSet(System.Data.IDbCommand cmd, object value, int index)
{
string mySetValue = FalseValue;
if( value.Equals(true) )
mySetValue = TrueValue;
m_stringType.Set(cmd, mySetValue, index);
}
public System.Type ReturnedType
{
get { return typeof(System.Boolean); }
}
public object NullSafeGet(System.Data.IDataReader rs, string[] names, object owner)
{
return m_stringType.NullSafeGet(rs, names).Equals(TrueValue);
}
public bool IsMutable
{
get { return m_stringType.IsMutable; }
}
}