System.Data.SQLite
Check-in [6886e6f4fb]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Modified to use the new utility type conversion helper(s) in SQLiteBase and SQLiteConvert
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | sourceforge
Files: files | file ages | folders
SHA1: 6886e6f4fb169be9aa68071fedb70ed7b5ac125a
User & Date: rmsimpson 2005-03-04 21:31:58
Context
2005-03-04
21:32
Latest build check-in: 972b7cde17 user: rmsimpson tags: sourceforge
21:31
Modified to use the new utility type conversion helper(s) in SQLiteBase and SQLiteConvert check-in: 6886e6f4fb user: rmsimpson tags: sourceforge
21:30
Increased performance ExecuteScalar() and ExecuteNonQuery() resulting in a nice boost in the insert 100k rows tests and user-function tests check-in: 5f06409677 user: rmsimpson tags: sourceforge
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to System.Data.SQLite/SQLiteDataReader.cs.

     8      8   namespace System.Data.SQLite
     9      9   {
    10     10     using System;
    11     11     using System.Data;
    12     12     using System.Data.Common;
    13     13     using System.Collections.Generic;
    14     14   
    15         -  internal struct SQLiteType
    16         -  {
    17         -    internal DbType         Type;
    18         -    internal TypeAffinity Affinity;
    19         -  }
    20         -
    21     15     /// <summary>
    22     16     /// SQLite implementation of DbDataReader.
    23     17     /// </summary>
    24     18     public sealed class SQLiteDataReader : DbDataReader
    25     19     {
    26     20       /// <summary>
    27     21       /// Underlying command this reader is attached to
................................................................................
    62     56       private CommandBehavior _commandBehavior;
    63     57   
    64     58       internal SQLiteDataReader(SQLiteCommand cmd, CommandBehavior behave)
    65     59       {
    66     60         _command = cmd;
    67     61         _commandBehavior = behave;
    68     62         Initialize();
           63  +
           64  +      if (_command != null)
           65  +        NextResult();
    69     66       }
    70     67   
    71     68       internal void Initialize()
    72     69       {
    73     70         _activeStatementIndex = -1;
    74     71         _activeStatement = null;
    75     72         _rowsAffected = -1;
    76     73         _fieldCount = -1;
    77         -
    78         -      NextResult();
    79     74       }
    80     75   
    81     76       /// <summary>
    82     77       /// Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified.
    83     78       /// </summary>
    84     79       public override void Close()
    85     80       {
    86     81         if (_command != null)
    87     82         {
    88         -        while (NextResult()) ;
           83  +        while (NextResult())
           84  +        {
           85  +        }
    89     86           _command.ClearDataReader();
    90     87         }
    91     88   
    92     89         // If the datareader's behavior includes closing the connection, then do so here.
    93     90         if ((_commandBehavior & CommandBehavior.CloseConnection) != 0)
    94     91           _command.Connection.Close();
    95     92   
................................................................................
   311    308       /// <summary>
   312    309       /// 
   313    310       /// </summary>
   314    311       /// <param name="ordinal"></param>
   315    312       /// <returns></returns>
   316    313       public override Type GetFieldType(int ordinal)
   317    314       {
   318         -      SQLiteType t = GetSQLiteType(ordinal);
   319         -
   320         -      if (t.Type != DbType.Object)
   321         -        return SQLiteConvert.DbTypeToType(t.Type);
   322         -
   323         -      switch (t.Affinity)
   324         -      {
   325         -        case TypeAffinity.Null:
   326         -          return typeof(DBNull);
   327         -        case TypeAffinity.Int64:
   328         -          return typeof(Int64);
   329         -        case TypeAffinity.Double:
   330         -          return typeof(Double);
   331         -        case TypeAffinity.Blob:
   332         -          return typeof(byte[]);
   333         -        default:
   334         -          return typeof(string);
   335         -      }
          315  +      return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(ordinal));
   336    316       }
   337    317   
   338    318       /// <summary>
   339    319       /// 
   340    320       /// </summary>
   341    321       /// <param name="ordinal"></param>
   342    322       /// <returns></returns>
................................................................................
   583    563       /// <summary>
   584    564       /// 
   585    565       /// </summary>
   586    566       /// <param name="ordinal"></param>
   587    567       /// <returns></returns>
   588    568       public override object GetValue(int ordinal)
   589    569       {
   590         -      if (IsDBNull(ordinal)) return DBNull.Value;
          570  +      SQLiteType typ = GetSQLiteType(ordinal);
   591    571   
   592         -      if (GetFieldType(ordinal) == typeof(byte[]))
   593         -      {
   594         -        int n = (int)GetBytes(ordinal, 0, null, 0, 0);
   595         -        byte[] b = new byte[n];
   596         -        GetBytes(ordinal, 0, b, 0, n);
   597         -
   598         -        return b;
   599         -      }
   600         -
   601         -      return Convert.ChangeType(_activeStatement._sql.GetText(_activeStatement, ordinal), GetFieldType(ordinal), null);
          572  +      return _activeStatement._sql.GetValue(_activeStatement, ordinal, ref typ);
   602    573       }
   603    574   
   604    575       /// <summary>
   605    576       /// 
   606    577       /// </summary>
   607    578       /// <param name="values"></param>
   608    579       /// <returns></returns>