Index: System.Data.SQLite/SQLiteConvert.cs
==================================================================
--- System.Data.SQLite/SQLiteConvert.cs
+++ System.Data.SQLite/SQLiteConvert.cs
@@ -2011,10 +2011,41 @@
internal DbType Type;
///
/// The affinity of a column, used for expressions or when Type is DbType.Object
///
internal TypeAffinity Affinity;
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ ///
+ /// Constructs a default instance of this type.
+ ///
+ public SQLiteType()
+ {
+ // do nothing.
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+
+ ///
+ /// Constructs an instance of this type with the specified field values.
+ ///
+ ///
+ /// The type affinity to use for the new instance.
+ ///
+ ///
+ /// The database type to use for the new instance.
+ ///
+ public SQLiteType(
+ TypeAffinity affinity,
+ DbType type
+ )
+ : this()
+ {
+ this.Affinity = affinity;
+ this.Type = type;
+ }
}
/////////////////////////////////////////////////////////////////////////////
internal sealed class SQLiteDbTypeMap
Index: System.Data.SQLite/SQLiteDataReader.cs
==================================================================
--- System.Data.SQLite/SQLiteDataReader.cs
+++ System.Data.SQLite/SQLiteDataReader.cs
@@ -359,11 +359,11 @@
private TypeAffinity VerifyType(int i, DbType typ)
{
CheckClosed();
CheckValidRow();
- TypeAffinity affinity = GetSQLiteType(i).Affinity;
+ TypeAffinity affinity = GetSQLiteType(SQLiteCommand.GetFlags(_command), i).Affinity;
switch (affinity)
{
case TypeAffinity.Int64:
if (typ == DbType.Int16) return affinity;
@@ -504,11 +504,11 @@
CheckDisposed();
if (i >= VisibleFieldCount && _keyInfo != null)
return _keyInfo.GetDataTypeName(i - VisibleFieldCount);
- SQLiteType typ = GetSQLiteType(i);
+ SQLiteType typ = GetSQLiteType(SQLiteCommand.GetFlags(_command), i);
if (typ.Type == DbType.Object) return SQLiteConvert.SQLiteTypeToType(typ).Name;
return _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity);
}
///
@@ -569,11 +569,11 @@
CheckDisposed();
if (i >= VisibleFieldCount && _keyInfo != null)
return _keyInfo.GetFieldType(i - VisibleFieldCount);
- return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i));
+ return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(SQLiteCommand.GetFlags(_command), i));
}
///
/// Returns a column as a float value
///
@@ -918,13 +918,15 @@
tbl.Columns.Add(SchemaTableOptionalColumn.DefaultValue, typeof(object));
tbl.Columns.Add("DataTypeName", typeof(string));
tbl.Columns.Add("CollationType", typeof(string));
tbl.BeginLoadData();
+ SQLiteConnectionFlags flags = SQLiteCommand.GetFlags(_command);
+
for (int n = 0; n < _fieldCount; n++)
{
- SQLiteType sqlType = GetSQLiteType(n);
+ SQLiteType sqlType = GetSQLiteType(flags, n);
row = tbl.NewRow();
DbType typ = sqlType.Type;
@@ -1131,14 +1133,14 @@
CheckValidRow();
if (i >= VisibleFieldCount && _keyInfo != null)
return _keyInfo.GetValue(i - VisibleFieldCount);
- SQLiteType typ = GetSQLiteType(i);
+ SQLiteConnectionFlags flags = SQLiteCommand.GetFlags(_command);
+ SQLiteType typ = GetSQLiteType(flags, i);
- return _activeStatement._sql.GetValue(
- _activeStatement, SQLiteCommand.GetFlags(_command), i, typ);
+ return _activeStatement._sql.GetValue(_activeStatement, flags, i, typ);
}
///
/// Retreives the values of multiple columns, up to the size of the supplied array
///
@@ -1413,13 +1415,14 @@
}
///
/// Retrieves the SQLiteType for a given column, and caches it to avoid repetetive interop calls.
///
+ /// The flags associated with the parent connection object.
/// The index of the column to retrieve
/// A SQLiteType structure
- private SQLiteType GetSQLiteType(int i)
+ private SQLiteType GetSQLiteType(SQLiteConnectionFlags flags, int i)
{
SQLiteType typ;
// Initialize the field types array if not already initialized
if (_fieldTypeArray == null)
@@ -1431,11 +1434,11 @@
typ = _fieldTypeArray[i];
// If not initialized, then fetch the declared column datatype and attempt to convert it
// to a known DbType.
if (typ.Affinity == TypeAffinity.Uninitialized)
- typ.Type = SQLiteConvert.TypeNameToDbType(GetConnection(this), _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity), GetFlags(this));
+ typ.Type = SQLiteConvert.TypeNameToDbType(GetConnection(this), _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity), flags);
else
typ.Affinity = _activeStatement._sql.ColumnAffinity(_activeStatement, i);
return typ;
}