I had a wrong return type in CreateInstance, after fixing the converter looks like
public class SomeConverterConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType.FullName == "System.String")
{
return true;
}
return false;
}
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
if (destinationType.FullName == "xxx.someStatus ")
{
return true;
}
return false;
}
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value == DBNull.Value
|| value == null)
{
return null;
}
if(Enum.GetName(typeof(someStatus ), someStatus .test1 ) == value.ToString())
{ return someStatus .test1; }
else
{
return someStatus .test2;
}
}
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
{
if (value == DBNull.Value
|| value == null)
{
return null;
}
return Enum.GetName(typeof(someStatus ), value);
}
public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues)
{
return someStatus .test2;
}
as previous is visible in tools but now can be applied to conversion.
After using it to conversion the reading is no problem, but while save i got:
An exception was caught during the execution of an action query: 42804: column \"ready_status\" is of type testenum.ready_status but expression is of type character varying. Check InnerException, QueryExecuted and Parameters of this exception to examine the ...
the query looks like
Query: UPDATE "test"."testenum" SET "modified_at"=NOW() at time zone 'utc' + '5s', "ready_status"=:p1 WHERE ( "test"."testenum"."id" = :p2)
Parameter: :p1 : String. Length: 10485760. Precision: 0. Scale: 0. Direction: Input. Value: "test1".
Parameter: :p2 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 181828831.