System.Data.SQLite

Check-in [64d7e6903e]
Login

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

Overview
Comment:When creating a parameter associated with a specific command, keep track of that command.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 64d7e6903e016e4226668038cdac1f1c132985d8
User & Date: mistachkin 2015-03-26 20:38:30.633
Context
2015-03-26
21:55
When BinaryGUID handling is off, transform the LINQ paramter types as well. Fix for [a4d9c7ee94]. check-in: 87b4244129 user: mistachkin tags: trunk
20:38
When creating a parameter associated with a specific command, keep track of that command. check-in: 64d7e6903e user: mistachkin tags: trunk
20:20
Make the DbType value of (-1) a constant in the parameter class. check-in: 30d638f582 user: mistachkin tags: trunk
Changes
Side-by-Side Diff Show Whitespace Changes Patch
Changes to System.Data.SQLite/SQLiteCommand.cs.
502
503
504
505
506
507
508
509

510
511
512
513
514
515
516
502
503
504
505
506
507
508

509
510
511
512
513
514
515
516







-
+







    /// <summary>
    /// Create a new parameter
    /// </summary>
    /// <returns></returns>
    public new SQLiteParameter CreateParameter()
    {
      CheckDisposed();
      return new SQLiteParameter();
      return new SQLiteParameter(this);
    }

    /// <summary>
    /// The connection associated with this command
    /// </summary>
#if !PLATFORM_COMPACTFRAMEWORK
    [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DbConnectionEditor, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
756
757
758
759
760
761
762
763
764
765
766










767
768
769
770
771
772
773
756
757
758
759
760
761
762




763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779







-
-
-
-
+
+
+
+
+
+
+
+
+
+







                {
                    command.CommandText = commandText;

                    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)
                    {
                        case SQLiteExecuteType.None:
                            {
Changes to System.Data.SQLite/SQLiteParameter.cs.
18
19
20
21
22
23
24




25
26
27
28
29
30
31
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35







+
+
+
+







  public sealed class SQLiteParameter : DbParameter, ICloneable
  {
    /// <summary>
    /// This value represents an "unknown" <see cref="DbType" />.
    /// </summary>
    private const DbType UnknownDbType = (DbType)(-1);

    /// <summary>
    /// The command associated with this parameter.
    /// </summary>
    private IDbCommand     _command;
    /// <summary>
    /// The data type of the parameter
    /// </summary>
    internal DbType        _dbType;
    /// <summary>
    /// The version information for mapping the parameter
    /// </summary>
45
46
47
48
49
50
51














52
53
54
55
56
57
58
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76







+
+
+
+
+
+
+
+
+
+
+
+
+
+







    /// <summary>
    /// The data size, unused by SQLite
    /// </summary>
    private int            _dataSize;

    private bool           _nullable;
    private bool           _nullMapping;

    /// <summary>
    /// Constructor used when creating for use with a specific command.
    /// </summary>
    /// <param name="command">
    /// The command associated with this parameter.
    /// </param>
    internal SQLiteParameter(
        IDbCommand command
        )
        : this()
    {
        _command = command;
    }

    /// <summary>
    /// Default constructor
    /// </summary>
    public SQLiteParameter() 
      : this(null, UnknownDbType, 0, null, DataRowVersion.Current)
    {
190
191
192
193
194
195
196
197

198
199
200
201
202
203
204
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222







-
+







      _sourceColumn = sourceColumn;
      _rowVersion = rowVersion;
      _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;
    }

    /// <summary>
    /// Constructs a named parameter of the specified type, size, source column and row version
    /// </summary>
275
276
277
278
279
280
281















282
283
284
285
286
287
288
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







    /// <param name="parameterSize">The size of the parameter</param>
    /// <param name="sourceColumn">The source column</param>
    /// <param name="rowVersion">The row version information</param>
    public SQLiteParameter(DbType parameterType, int parameterSize, string sourceColumn, DataRowVersion rowVersion)
      : this(null, parameterType, parameterSize, sourceColumn, rowVersion)
    {
    }

    /// <summary>
    /// The command associated with this parameter.
    /// </summary>
    public IDbCommand Command
    {
      get
      {
        return _command;
      }
      set 
      {
        _command = value;
      }
    }

    /// <summary>
    /// Whether or not the parameter can contain a null value
    /// </summary>
    public override bool IsNullable
    {
      get
310
311
312
313
314
315
316
317

318
319
320
321
322
323
324
343
344
345
346
347
348
349

350
351
352
353
354
355
356
357







-
+







        {
          if (_objValue != null && _objValue != DBNull.Value)
          {
            return SQLiteConvert.TypeToDbType(_objValue.GetType());
          }
          return DbType.String; // Unassigned default value is String
        }
        return (DbType)_dbType;
        return _dbType;
      }
      set
      {
        _dbType = value;
      }
    }