Index: System.Data.SQLite/SQLiteCommand.cs
==================================================================
--- System.Data.SQLite/SQLiteCommand.cs
+++ System.Data.SQLite/SQLiteCommand.cs
@@ -504,11 +504,11 @@
///
///
public new SQLiteParameter CreateParameter()
{
CheckDisposed();
- return new SQLiteParameter();
+ return new SQLiteParameter(this);
}
///
/// The connection associated with this command
///
@@ -758,14 +758,20 @@
if (args != null)
{
foreach (object arg in args)
{
- if (arg is SQLiteParameter)
- command.Parameters.Add((SQLiteParameter)arg);
- else
- command.Parameters.Add(new SQLiteParameter(DbType.Object, arg));
+ SQLiteParameter parameter = arg as SQLiteParameter;
+
+ if (parameter == null)
+ {
+ parameter = command.CreateParameter();
+ parameter.DbType = DbType.Object;
+ parameter.Value = arg;
+ }
+
+ command.Parameters.Add(parameter);
}
}
switch (executeType)
{
Index: System.Data.SQLite/SQLiteParameter.cs
==================================================================
--- System.Data.SQLite/SQLiteParameter.cs
+++ System.Data.SQLite/SQLiteParameter.cs
@@ -20,10 +20,14 @@
///
/// This value represents an "unknown" .
///
private const DbType UnknownDbType = (DbType)(-1);
+ ///
+ /// The command associated with this parameter.
+ ///
+ private IDbCommand _command;
///
/// The data type of the parameter
///
internal DbType _dbType;
///
@@ -47,10 +51,24 @@
///
private int _dataSize;
private bool _nullable;
private bool _nullMapping;
+
+ ///
+ /// Constructor used when creating for use with a specific command.
+ ///
+ ///
+ /// The command associated with this parameter.
+ ///
+ internal SQLiteParameter(
+ IDbCommand command
+ )
+ : this()
+ {
+ _command = command;
+ }
///
/// Default constructor
///
public SQLiteParameter()
@@ -192,11 +210,11 @@
_dataSize = parameterSize;
_nullable = true;
}
private SQLiteParameter(SQLiteParameter source)
- : this(source.ParameterName, (DbType)source._dbType, 0, source.Direction, source.IsNullable, 0, 0, source.SourceColumn, source.SourceVersion, source.Value)
+ : this(source.ParameterName, source._dbType, 0, source.Direction, source.IsNullable, 0, 0, source.SourceColumn, source.SourceVersion, source.Value)
{
_nullMapping = source._nullMapping;
}
///
@@ -277,10 +295,25 @@
/// The row version information
public SQLiteParameter(DbType parameterType, int parameterSize, string sourceColumn, DataRowVersion rowVersion)
: this(null, parameterType, parameterSize, sourceColumn, rowVersion)
{
}
+
+ ///
+ /// The command associated with this parameter.
+ ///
+ public IDbCommand Command
+ {
+ get
+ {
+ return _command;
+ }
+ set
+ {
+ _command = value;
+ }
+ }
///
/// Whether or not the parameter can contain a null value
///
public override bool IsNullable
@@ -312,11 +345,11 @@
{
return SQLiteConvert.TypeToDbType(_objValue.GetType());
}
return DbType.String; // Unassigned default value is String
}
- return (DbType)_dbType;
+ return _dbType;
}
set
{
_dbType = value;
}