Error applying ResultMap when using 'Guid' in resultClass
---------------------------------------------------------
Key: IBATISNET-25
URL: http://issues.apache.org/jira/browse/IBATISNET-25
Project: iBatis for .NET
Type: Bug
Versions: DataMaper 1.5, DataAccess 1.5
Reporter: Henrik Uffe Jensen
Ran into a few other problems using 'Guid' in resultClass of a statement.
IBatisNet.DataMapper.Configuration.Statements.CreateInstanceOfResultClass()
contains
the lines:
if (_resultClass.GetType() == typeof(Guid))
{
return Guid.NewGuid();
}
but they doesn't work as expected. A 'Guid' resultClass has a
System.RuntimeType as type so the Guid.NewGuid() isn't used. I instead did the
following using the FullName of the resultClass and the string representation
of the type.
if (_resultClass.FullName == typeof(Guid).ToString())
{
return Guid.NewGuid();
}
Next thing then in IBatisNet.DataMapper.MappedStatements.ApplyResultMap, just
below the above method is called, then the following lines is being used to
check if resultClass is a primitive type. However Type.GetTypeCode() with a
'Guid' type returns TypeCode.Object and therefore goes further on.
// Check if the ResultClass is a 'primitive' Type
if (Type.GetTypeCode(outObject.GetType()) != TypeCode.Object)
I changed the code to be
// Check if the ResultClass is a 'primitive' Type or a Guid
if (Type.GetTypeCode(outObject.GetType()) != TypeCode.Object ||
outObject.GetType() == typeof(Guid))
This works fine for 'Guid' then. I haven't looked into if other datatypes need
the same special handling as Guid
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.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