[ http://issues.apache.org/jira/browse/IBATISNET-46?page=all ]
     
Gilles Bayon closed IBATISNET-46:
---------------------------------

     Resolution: Fixed
    Fix Version: DataMapper 1.2

> IBatisNet incorrectly assumes that Command and Connection providers will 
> implement System.IConeable
> ---------------------------------------------------------------------------------------------------
>
>          Key: IBATISNET-46
>          URL: http://issues.apache.org/jira/browse/IBATISNET-46
>      Project: iBatis for .NET
>         Type: Bug
>     Versions: DataMapper 1.1
>  Environment: [assembly: AssemblyVersion("1.1.458")]
>     Reporter: Ron Grabowski
>     Assignee: Gilles Bayon
>      Fix For: DataMapper 1.2

>
> Classes that implement IDbCommand, IDbConnection, etc. are not required to 
> implement the System.ICloneable interface. For example the SQLite.NET client:
>  http://sourceforge.net/projects/adodotnetsqlite
> does not. The following line in Provider.cs causes a cast exception becuase 
> it assumes the object implements ICloneable:
> public IDbCommand GetCommand()
> {
>  return (IDbCommand) Activator.CreateInstance(_templateCommand.GetType());
> }
> It should be changed to:
> public IDbCommand GetCommand()
> {
>  if (_templateCommand is ICloneable)
>  {
>   return (IDbCommand) ((ICloneable)_templateCommand).Clone();
>  }
>  else
>  {
>   return (IDbCommand) Activator.CreateInstance(_templateCommand.GetType());
>  }
> }
> If you're paranoid about speed, the check for IConeable could be done a 
> single time inside of the Initialisation() method of the same class and the 
> value could be stored as a bool:
>  bool _templateCommandIsICloneable = _templateCommand is ICloneable;
> then used later:
> public IDbCommand GetCommand()
> {
>  if (_templateCommandIsICloneable)
>  {
>   return (IDbCommand) ((ICloneable)_templateCommand).Clone();
>  }
>  else
>  {
>   return (IDbCommand) Activator.CreateInstance(_templateCommand.GetType());
>  }
> }
> GetConnection() and GetDataAdapter() should also be changed.

-- 
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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to