Необходимо создать карту (m => m.EmployeeId) .CustomType (typeof (IntConvertToNullInt));
открытый класс IntConvertToNullInt: IUserType {public SqlType [] SqlTypes {get {return new [] {SqlTypeFactory.Int32};}}
public Type ReturnedType
{
get { return typeof(Int32); }
}
public bool IsMutable
{
get { return false; }
}
public int GetHashCode(object x)
{
if (x == null)
{
return 0;
}
return x.GetHashCode();
}
public object NullSafeGet(IDataReader rs, string[] names, object owner)
{
object obj = NHibernateUtil.Int32.NullSafeGet(rs, names[0]);
if (obj == null)
{
return 0;
}
return Convert.ToInt32(obj);
}
public void NullSafeSet(IDbCommand cmd, object value, int index)
{
if (value == null)
{
NHibernateUtil.Int32.NullSafeSet(cmd, null, index);
return;
}
else
{
int indexint = (int)value;
if (indexint == 0)
{
NHibernateUtil.Int32.NullSafeSet(cmd, null, index);
}
else
{
NHibernateUtil.Int32.NullSafeSet(cmd, value, index);
}
}
}
public object DeepCopy(object value)
{
return value;
}
public object Replace(object original, object target, object owner)
{
return original;
}
public object Assemble(object cached, object owner)
{
return cached;
}
public object Disassemble(object value)
{
return value;
}
bool IUserType.Equals(object x, object y)
{
return object.Equals(x, y);
}