/******************************************************** * ADO.NET 2.0 Data Provider for SQLite Version 3.X * Written by Robert Simpson (robert@blackcastlesoft.com) * * Released to the public domain, use at your own risk! ********************************************************/ namespace System.Data.SQLite { using System; using System.Data; using System.Data.Common; /// /// SQLite implementation of DbParameter. /// public sealed class SQLiteParameter : DbParameter { private int _dbType; private DataRowVersion _rowVersion; private Object _objValue; private string _sourceColumn; private string _columnName; private int _dataSize; /// /// /// public SQLiteParameter() { Initialize(null, -1, 0, null, DataRowVersion.Current); } /// /// /// /// public SQLiteParameter(string parameterName) { Initialize(parameterName, -1, 0, null, DataRowVersion.Current); } /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType) { Initialize(parameterName, (int)dbType, 0, null, DataRowVersion.Current); } /// /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType, string sourceColumn) { Initialize(parameterName, (int)dbType, 0, sourceColumn, DataRowVersion.Current); } /// /// /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType, string sourceColumn, DataRowVersion rowVersion) { Initialize(parameterName, (int)dbType, 0, sourceColumn, rowVersion); } /// /// /// /// public SQLiteParameter(DbType dbType) { Initialize(null, (int)dbType, 0, null, DataRowVersion.Current); } /// /// /// /// /// public SQLiteParameter(DbType dbType, string sourceColumn) { Initialize(null, (int)dbType, 0, sourceColumn, DataRowVersion.Current); } /// /// /// /// /// /// public SQLiteParameter(DbType dbType, string sourceColumn, DataRowVersion rowVersion) { Initialize(null, (int)dbType, 0, sourceColumn, rowVersion); } /// /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType, int nSize) { Initialize(parameterName, (int)dbType, nSize, null, DataRowVersion.Current); } /// /// /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType, int nSize, string sourceColumn) { Initialize(parameterName, (int)dbType, nSize, sourceColumn, DataRowVersion.Current); } /// /// /// /// /// /// /// /// public SQLiteParameter(string parameterName, DbType dbType, int nSize, string sourceColumn, DataRowVersion rowVersion) { Initialize(parameterName, (int)dbType, nSize, sourceColumn, rowVersion); } /// /// /// /// /// public SQLiteParameter(DbType dbType, int nSize) { Initialize(null, (int)dbType, nSize, null, DataRowVersion.Current); } /// /// /// /// /// /// public SQLiteParameter(DbType dbType, int nSize, string sourceColumn) { Initialize(null, (int)dbType, nSize, sourceColumn, DataRowVersion.Current); } /// /// /// /// /// /// /// public SQLiteParameter(DbType dbType, int nSize, string sourceColumn, DataRowVersion rowVersion) { Initialize(null, (int)dbType, nSize, sourceColumn, rowVersion); } /// /// /// /// /// /// /// /// private void Initialize(string parameterName, int dbType, int nSize, string sourceColumn, DataRowVersion rowVersion) { _columnName = parameterName; _dbType = dbType; _sourceColumn = sourceColumn; _rowVersion = rowVersion; _objValue = null; _dataSize = nSize; } /// /// /// public override bool IsNullable { get { return true; } set { } } /// /// /// /// [Obsolete] public override void CopyTo(DbParameter destination) { throw new NotImplementedException(); } /// /// /// public override DbType DbType { get { if (_dbType == -1) return DbType.String; // Unassigned default value is String return (DbType)_dbType; } set { _dbType = (int)value; } } /// /// /// public override ParameterDirection Direction { get { return ParameterDirection.Input; } set { if (value != ParameterDirection.Input) throw new NotImplementedException(); } } /// /// /// public override int Offset { get { throw new NotImplementedException(); } set { } } /// /// /// public override string ParameterName { get { return _columnName; } set { _columnName = value; } } /// /// /// public override void ResetDbType() { throw new NotImplementedException(); } /// /// /// public override int Size { get { return _dataSize; } set { _dataSize = value; } } /// /// /// public override string SourceColumn { get { return _sourceColumn; } set { _sourceColumn = value; } } /// /// /// public override bool SourceColumnNullMapping { get { return false; } set { } } /// /// /// public override DataRowVersion SourceVersion { get { return _rowVersion; } set { _rowVersion = value; } } /// /// /// public override object Value { get { return _objValue; } set { _objValue = value; if (_dbType == -1 && _objValue != null && _objValue != DBNull.Value) // If the DbType has never been assigned, try to glean one from the value's datatype _dbType = (int)SQLiteConvert.TypeToDbType(_objValue.GetType()); } } } }