I've mostly gotten NHibernate to play nice with the Informix ADO.NET provider, but I'm running into a problem with the way Enum parameters work. The offending code is in NHibernate.Type.PersistentEnumType:
Code:
public override void Set(IDbCommand cmd, object value, int index)
{
IDataParameter par = (IDataParameter) cmd.Parameters[index];
if (value == null)
{
par.Value = DBNull.Value;
}
else
{
par.Value = value; // <--- This is causing the problem
}
}
When NHibernate sets the parameter value it assumes that the ADO.NET provider will convert the Enum type into the appropriate underlying type. This seems to work fine with most ADO.NET providers, but Informix chokes on it (it complains that the enumerated type is not blittable).
There is already a method in the same class called "GetValue", which is used to handle Oracle's improper type conversion by the provider, but it is only called from the "Get" method. I've found that adding a call to "GetValue" in the "Set" method solves my Informix problem. Any chance we can add this to the trunk? My patch is copied below:
Code:
Index: NHibernate/Type/PersistentEnumType.cs
===================================================================
--- NHibernate/Type/PersistentEnumType.cs (revision 3071)
+++ NHibernate/Type/PersistentEnumType.cs (working copy)
@@ -151,7 +151,7 @@
}
else
{
- par.Value = value;
+ par.Value = GetValue(value);
}
}