nullValue not working with GUIDs
--------------------------------
Key: IBATISNET-13
URL: http://nagoya.apache.org/jira/browse/IBATISNET-13
Project: iBatis for .NET
Type: Bug
Reporter: Henrik Uffe Jensen
Convert.ChangeType for some reason does not support GUIDs, so when the
'nullValue' attribute is used on a parameter in a parameterMap an exception is
thrown.
In
IBatisNet.DataMapper.Configuration.ParameterMapping.ParameterMap.GetValueOfProperty()
the nullValue to use for comparing is retrieved with the following code, where
the Convert.ChangeType does not like a Guid
if (propertyInfo.PropertyType == typeof(System.Decimal))
{
CultureInfo culture = new CultureInfo( "en-US" );
// nullValue decimal must be ######.##
nullValue = decimal.Parse( property.NullValue, culture);
}
else
{
nullValue = Convert.ChangeType( property.NullValue,
propertyInfo.PropertyType );
}
The solution is to handle GUIDs as a special case just as is already done with
Decimal values. I tested with the following code and
nullValue="00000000-0000-0000-0000-000000000000" and then using Guid.Empty on
my properties and it worked fine
if (propertyInfo.PropertyType == typeof(System.Decimal))
{
CultureInfo culture = new CultureInfo( "en-US" );
// nullValue decimal must be ######.##
nullValue = decimal.Parse( property.NullValue, culture);
}
else if (propertyInfo.PropertyType == typeof(System.Guid))
{
nullValue = new Guid(property.NullValue);
}
else
{
nullValue = Convert.ChangeType( property.NullValue,
propertyInfo.PropertyType );
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://nagoya.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira