I've got an object that uses System.Version as a property. I want this object to be mapped into my table, storing the version as a string. what's the best way to go about doing this with NHibernate v1.2?
public class MyClass
{
public Version MyVersion {get; set;}
}
not sure what to do with the propery mapping
<property name="MyVersion" column="MyVersion" not-null="true" />
this gives me errors saying "Invalid attempt to GetBytes on column 'MyVersion0_0_'. The GetBytes function can only be used on columns of type Text, NText, or Image." If I use type="string" in the map, i get casting errors.
suggestions?
Best Answer
You would need to write an NHibernate user type, that returns a property value of type Version, but persists as a string. There is a skeleton user type implementation here that takes care of some of the work for you.