Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch IDisposablePattern Excluding Merge-Ins
This is equivalent to a diff from f58dc30e00 to b48037de03
2011-12-16
| ||
04:31 | Merge all IDisposable pattern fixes to trunk. check-in: 419bfbd2ee user: mistachkin tags: trunk | |
04:28 | Update test count on test procedures wiki page. Closed-Leaf check-in: b48037de03 user: mistachkin tags: IDisposablePattern | |
04:25 | Compilation error fixes. check-in: 8dfdf59c72 user: mistachkin tags: IDisposablePattern | |
03:32 | Start of making sure that all core components containing IDisposable objects implement IDisposable and that they follow the established best-practices when doing so. check-in: c532a87e4d user: mistachkin tags: IDisposablePattern | |
03:28 | Add missing file header to various files. check-in: f58dc30e00 user: mistachkin tags: trunk | |
2011-12-13
| ||
10:09 | When creating MockRegistryKey objects, use the new constructors that require the readOnly and safe arguments. check-in: 64686e6685 user: mistachkin tags: trunk | |
Changes to SQLite.NET.Settings.targets.
︙ | ︙ | |||
102 103 104 105 106 107 108 109 110 111 112 113 114 115 | <IsCompactFramework Condition="'$(IsCompactFramework)' == ''">false</IsCompactFramework> <!-- NOTE: Emit an AssemblyFlags attribute that includes the Retargetable flag from the AssemblyNameFlags enumeration? --> <IsRetargetable Condition="'$(IsRetargetable)' == ''">false</IsRetargetable> </PropertyGroup> <!-- ****************************************************************************** ** Warning Properties ** ****************************************************************************** --> | > > > > > > > > | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | <IsCompactFramework Condition="'$(IsCompactFramework)' == ''">false</IsCompactFramework> <!-- NOTE: Emit an AssemblyFlags attribute that includes the Retargetable flag from the AssemblyNameFlags enumeration? --> <IsRetargetable Condition="'$(IsRetargetable)' == ''">false</IsRetargetable> <!-- NOTE: Throw an exception if an object has already been disposed? By default, this is enabled. If this is disabled, an exception will not be thrown when a SQLite object which has already been disposed is accessed. --> <ThrowOnDisposed Condition="'$(ThrowOnDisposed)' == ''">true</ThrowOnDisposed> </PropertyGroup> <!-- ****************************************************************************** ** Warning Properties ** ****************************************************************************** --> |
︙ | ︙ | |||
168 169 170 171 172 173 174 | ****************************************************************************** ** Strong Name Signing Properties ** ****************************************************************************** --> <PropertyGroup Condition="'$(SQLiteNetDir)' != '' And !HasTrailingSlash('$(SQLiteNetDir)') And | | > | 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | ****************************************************************************** ** Strong Name Signing Properties ** ****************************************************************************** --> <PropertyGroup Condition="'$(SQLiteNetDir)' != '' And !HasTrailingSlash('$(SQLiteNetDir)') And (('$(IsCompactFramework)' == 'false' And Exists('$(SQLiteNetDir)\System.Data.SQLite\System.Data.SQLite.snk')) Or ('$(IsCompactFramework)' != 'false' And Exists('$(SQLiteNetDir)\System.Data.SQLite\System.Data.SQLite.CF.snk')))"> <!-- NOTE: Sign the assembly? By default, this is enabled. --> <SignAssembly Condition="'$(SignAssembly)' == ''">true</SignAssembly> <!-- NOTE: Use delay signing? By default, this is disabled because the |
︙ | ︙ |
Changes to System.Data.SQLite/AssemblyInfo.cs.
1 2 3 4 5 6 7 | using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Resources; #if !PLATFORM_COMPACTFRAMEWORK | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /******************************************************** * 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! ********************************************************/ using System; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Resources; #if !PLATFORM_COMPACTFRAMEWORK |
︙ | ︙ | |||
29 30 31 32 33 34 35 | #endif // Setting ComVisible to false makes the types in this assembly not visible // to COM componenets. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] | | | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #endif // Setting ComVisible to false makes the types in this assembly not visible // to COM componenets. If you need to access a type in this assembly from // COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] [assembly: CLSCompliant(true)] [assembly: InternalsVisibleTo("System.Data.SQLite.Linq, PublicKey=" + System.Data.SQLite.SQLite3.PublicKey)] [assembly: NeutralResourcesLanguage("en")] #if !PLATFORM_COMPACTFRAMEWORK [assembly: AllowPartiallyTrustedCallers] [assembly: ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] #if !NET_20 |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3.cs.
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 | internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message); /// <summary> /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET /// </summary> internal class SQLite3 : SQLiteBase { #if !PLATFORM_COMPACTFRAMEWORK internal const string DesignerVersion = "1.0.77.0"; #endif /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> | > > > > > > > > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | internal delegate void SQLiteLogCallback(IntPtr puser, int err_code, IntPtr message); /// <summary> /// This class implements SQLiteBase completely, and is the guts of the code that interop's SQLite with .NET /// </summary> internal class SQLite3 : SQLiteBase { // // NOTE: This is the public key for the System.Data.SQLite assembly. If you change the // SNK file, you will need to change this as well. // internal const string PublicKey = "002400000480000094000000060200000024000052534131000400000100010005a288de5687c4e1" + "b621ddff5d844727418956997f475eb829429e411aff3e93f97b70de698b972640925bdd44280df0" + "a25a843266973704137cbb0e7441c1fe7cae4e2440ae91ab8cde3933febcb1ac48dd33b40e13c421" + "d8215c18a4349a436dd499e3c385cc683015f886f6c10bd90115eb2bd61b67750839e3a19941dc9c"; #if !PLATFORM_COMPACTFRAMEWORK internal const string DesignerVersion = "1.0.77.0"; #endif /// <summary> /// The opaque pointer returned to us by the sqlite provider /// </summary> |
︙ | ︙ | |||
44 45 46 47 48 49 50 | protected SQLiteFunction[] _functionsArray; internal SQLite3(SQLiteDateFormats fmt, DateTimeKind kind) : base(fmt, kind) { } | > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | | > > > > > > > > > > > | | | | | | > | | < | | > > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | protected SQLiteFunction[] _functionsArray; internal SQLite3(SQLiteDateFormats fmt, DateTimeKind kind) : base(fmt, kind) { } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLite3).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// Close(); disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// // It isn't necessary to cleanup any functions we've registered. If the connection // goes to the pool and is resurrected later, re-registered functions will overwrite the // previous functions. The SQLiteFunctionCookieHandle will take care of freeing unmanaged // resources belonging to the previously-registered functions. internal override void Close() { if (_sql != null) { if (_usePool) { SQLiteBase.ResetConnection(_sql); SQLiteConnectionPool.Add(_fileName, _sql, _poolVersion); } else { _sql.Dispose(); } _sql = null; } } /////////////////////////////////////////////////////////////////////////////////////////////// internal override void Cancel() { UnsafeNativeMethods.sqlite3_interrupt(_sql); } internal override string Version |
︙ | ︙ |
Changes to System.Data.SQLite/SQLite3_UTF16.cs.
︙ | ︙ | |||
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | internal class SQLite3_UTF16 : SQLite3 { internal SQLite3_UTF16(SQLiteDateFormats fmt, DateTimeKind kind) : base(fmt, kind) { } /// <summary> /// Overrides SQLiteConvert.ToString() to marshal UTF-16 strings instead of UTF-8 /// </summary> /// <param name="b">A pointer to a UTF-16 string</param> /// <param name="nbytelen">The length (IN BYTES) of the string</param> /// <returns>A .NET string</returns> public override string ToString(IntPtr b, int nbytelen) { return UTF16ToString(b, nbytelen); } public static string UTF16ToString(IntPtr b, int nbytelen) { if (nbytelen == 0 || b == IntPtr.Zero) return ""; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 | internal class SQLite3_UTF16 : SQLite3 { internal SQLite3_UTF16(SQLiteDateFormats fmt, DateTimeKind kind) : base(fmt, kind) { } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLite3_UTF16).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Overrides SQLiteConvert.ToString() to marshal UTF-16 strings instead of UTF-8 /// </summary> /// <param name="b">A pointer to a UTF-16 string</param> /// <param name="nbytelen">The length (IN BYTES) of the string</param> /// <returns>A .NET string</returns> public override string ToString(IntPtr b, int nbytelen) { CheckDisposed(); return UTF16ToString(b, nbytelen); } public static string UTF16ToString(IntPtr b, int nbytelen) { if (nbytelen == 0 || b == IntPtr.Zero) return ""; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteBase.cs.
︙ | ︙ | |||
218 219 220 221 222 223 224 | internal abstract bool AutoCommit { get; } internal abstract int FileControl(string zDbName, int op, IntPtr pArg); | > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > | > > > | > > > | > > > > > | > | | > | 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | internal abstract bool AutoCommit { get; } internal abstract int FileControl(string zDbName, int op, IntPtr pArg); /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteBase).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void Dispose(bool disposing) { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteBase() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// // These statics are here for lack of a better place to put them. // They exist here because they are called during the finalization of // a SQLiteStatementHandle, SQLiteConnectionHandle, and SQLiteFunctionCookieHandle. // Therefore these functions have to be static, and have to be low-level. internal static string SQLiteLastError(SQLiteConnectionHandle db) |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteCommand.cs.
︙ | ︙ | |||
139 140 141 142 143 144 145 146 147 148 149 150 151 | _commandTimeout = connection.DefaultTimeout; } if (transaction != null) Transaction = transaction; } /// <summary> /// Disposes of the command and clears all member variables /// </summary> /// <param name="disposing">Whether or not the class is being explicitly or implicitly disposed</param> protected override void Dispose(bool disposing) { | > > > > > > > > > > > > > > > > | | | | > > > > | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > | 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | _commandTimeout = connection.DefaultTimeout; } if (transaction != null) Transaction = transaction; } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteCommand).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Disposes of the command and clears all member variables /// </summary> /// <param name="disposing">Whether or not the class is being explicitly or implicitly disposed</param> protected override void Dispose(bool disposing) { try { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// // If a reader is active on this command, don't destroy the command, instead let the reader do it SQLiteDataReader reader = null; if (_activeReader != null) { try { reader = _activeReader.Target as SQLiteDataReader; } catch (InvalidOperationException) { } } if (reader != null) { reader._disposeCommand = true; _activeReader = null; return; } Connection = null; _parameterCollection.Clear(); _commandText = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Clears and destroys all statements currently prepared /// </summary> internal void ClearCommands() { if (_activeReader != null) |
︙ | ︙ | |||
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | } /// <summary> /// Not implemented /// </summary> public override void Cancel() { if (_activeReader != null) { SQLiteDataReader reader = _activeReader.Target as SQLiteDataReader; if (reader != null) reader.Cancel(); } } /// <summary> /// The SQL command text associated with the command /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue(""), RefreshProperties(RefreshProperties.All), Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlCommandTextEditor, 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")] #endif public override string CommandText { get { return _commandText; } set { if (_commandText == value) return; if (_activeReader != null && _activeReader.IsAlive) { throw new InvalidOperationException("Cannot set CommandText while a DataReader is active"); } | > > > > > | 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 | } /// <summary> /// Not implemented /// </summary> public override void Cancel() { CheckDisposed(); if (_activeReader != null) { SQLiteDataReader reader = _activeReader.Target as SQLiteDataReader; if (reader != null) reader.Cancel(); } } /// <summary> /// The SQL command text associated with the command /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue(""), RefreshProperties(RefreshProperties.All), Editor("Microsoft.VSDesigner.Data.SQL.Design.SqlCommandTextEditor, 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")] #endif public override string CommandText { get { CheckDisposed(); return _commandText; } set { CheckDisposed(); if (_commandText == value) return; if (_activeReader != null && _activeReader.IsAlive) { throw new InvalidOperationException("Cannot set CommandText while a DataReader is active"); } |
︙ | ︙ | |||
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((int)30)] #endif public override int CommandTimeout { get { return _commandTimeout; } set { _commandTimeout = value; } } /// <summary> /// The type of the command. SQLite only supports CommandType.Text /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [RefreshProperties(RefreshProperties.All), DefaultValue(CommandType.Text)] #endif public override CommandType CommandType { get { return CommandType.Text; } set { if (value != CommandType.Text) { throw new NotSupportedException(); } } } | > > > > > | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((int)30)] #endif public override int CommandTimeout { get { CheckDisposed(); return _commandTimeout; } set { CheckDisposed(); _commandTimeout = value; } } /// <summary> /// The type of the command. SQLite only supports CommandType.Text /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [RefreshProperties(RefreshProperties.All), DefaultValue(CommandType.Text)] #endif public override CommandType CommandType { get { CheckDisposed(); return CommandType.Text; } set { CheckDisposed(); if (value != CommandType.Text) { throw new NotSupportedException(); } } } |
︙ | ︙ | |||
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | /// <summary> /// Create a new parameter /// </summary> /// <returns></returns> public new SQLiteParameter CreateParameter() { return new SQLiteParameter(); } /// <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")] #endif public new SQLiteConnection Connection { | > | > > | 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | /// <summary> /// Create a new parameter /// </summary> /// <returns></returns> public new SQLiteParameter CreateParameter() { CheckDisposed(); return new SQLiteParameter(); } /// <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")] #endif public new SQLiteConnection Connection { get { CheckDisposed(); return _cnn; } set { CheckDisposed(); if (_activeReader != null && _activeReader.IsAlive) throw new InvalidOperationException("Cannot set Connection while a DataReader is active"); if (_cnn != null) { ClearCommands(); //_cnn.RemoveCommand(this); |
︙ | ︙ | |||
424 425 426 427 428 429 430 | /// Returns the SQLiteParameterCollection for the given command /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] #endif public new SQLiteParameterCollection Parameters { | | | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | /// Returns the SQLiteParameterCollection for the given command /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] #endif public new SQLiteParameterCollection Parameters { get { CheckDisposed(); return _parameterCollection; } } /// <summary> /// Forwards to the local Parameters property /// </summary> protected override DbParameterCollection DbParameterCollection { |
︙ | ︙ | |||
447 448 449 450 451 452 453 | /// command's underlying connection. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] #endif public new SQLiteTransaction Transaction { | | > > | 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 | /// command's underlying connection. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] #endif public new SQLiteTransaction Transaction { get { CheckDisposed(); return _transaction; } set { CheckDisposed(); if (_cnn != null) { if (_activeReader != null && _activeReader.IsAlive) throw new InvalidOperationException("Cannot set Transaction while a DataReader is active"); if (value != null) { |
︙ | ︙ | |||
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 | /// <summary> /// Overrides the default behavior to return a SQLiteDataReader specialization class /// </summary> /// <param name="behavior">The flags to be associated with the reader</param> /// <returns>A SQLiteDataReader</returns> public new SQLiteDataReader ExecuteReader(CommandBehavior behavior) { InitializeForReader(); SQLiteDataReader rd = new SQLiteDataReader(this, behavior); _activeReader = new WeakReference(rd, false); return rd; } /// <summary> /// Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class /// </summary> /// <returns>A SQLiteDataReader</returns> public new SQLiteDataReader ExecuteReader() { return ExecuteReader(CommandBehavior.Default); } /// <summary> /// Called by the SQLiteDataReader when the data reader is closed. /// </summary> internal void ClearDataReader() { _activeReader = null; } /// <summary> /// Execute the command and return the number of rows inserted/updated affected by it. /// </summary> /// <returns></returns> public override int ExecuteNonQuery() { using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult)) { while (reader.NextResult()) ; return reader.RecordsAffected; } } /// <summary> /// Execute the command and return the first column of the first row of the resultset /// (if present), or null if no resultset was returned. /// </summary> /// <returns>The first column of the first row of the first resultset from the query</returns> public override object ExecuteScalar() { using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult)) { if (reader.Read()) return reader[0]; } return null; } /// <summary> /// Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards. /// </summary> public override void Prepare() { } /// <summary> /// Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable. /// </summary> [DefaultValue(UpdateRowSource.None)] public override UpdateRowSource UpdatedRowSource { get { return _updateRowSource; } set { _updateRowSource = value; } } /// <summary> /// Determines if the command is visible at design time. Defaults to True. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DesignOnly(true), Browsable(false), DefaultValue(true), EditorBrowsable(EditorBrowsableState.Never)] #endif public override bool DesignTimeVisible { get { return _designTimeVisible; } set { _designTimeVisible = value; #if !PLATFORM_COMPACTFRAMEWORK TypeDescriptor.Refresh(this); #endif } } /// <summary> /// Clones a command, including all its parameters /// </summary> /// <returns>A new SQLiteCommand with the same commandtext, connection and parameters</returns> public object Clone() { return new SQLiteCommand(this); } } } | > > > > > > > > > > > > > | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 | /// <summary> /// Overrides the default behavior to return a SQLiteDataReader specialization class /// </summary> /// <param name="behavior">The flags to be associated with the reader</param> /// <returns>A SQLiteDataReader</returns> public new SQLiteDataReader ExecuteReader(CommandBehavior behavior) { CheckDisposed(); InitializeForReader(); SQLiteDataReader rd = new SQLiteDataReader(this, behavior); _activeReader = new WeakReference(rd, false); return rd; } /// <summary> /// Overrides the default behavior of DbDataReader to return a specialized SQLiteDataReader class /// </summary> /// <returns>A SQLiteDataReader</returns> public new SQLiteDataReader ExecuteReader() { CheckDisposed(); return ExecuteReader(CommandBehavior.Default); } /// <summary> /// Called by the SQLiteDataReader when the data reader is closed. /// </summary> internal void ClearDataReader() { _activeReader = null; } /// <summary> /// Execute the command and return the number of rows inserted/updated affected by it. /// </summary> /// <returns></returns> public override int ExecuteNonQuery() { CheckDisposed(); using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult)) { while (reader.NextResult()) ; return reader.RecordsAffected; } } /// <summary> /// Execute the command and return the first column of the first row of the resultset /// (if present), or null if no resultset was returned. /// </summary> /// <returns>The first column of the first row of the first resultset from the query</returns> public override object ExecuteScalar() { CheckDisposed(); using (SQLiteDataReader reader = ExecuteReader(CommandBehavior.SingleRow | CommandBehavior.SingleResult)) { if (reader.Read()) return reader[0]; } return null; } /// <summary> /// Does nothing. Commands are prepared as they are executed the first time, and kept in prepared state afterwards. /// </summary> public override void Prepare() { CheckDisposed(); } /// <summary> /// Sets the method the SQLiteCommandBuilder uses to determine how to update inserted or updated rows in a DataTable. /// </summary> [DefaultValue(UpdateRowSource.None)] public override UpdateRowSource UpdatedRowSource { get { CheckDisposed(); return _updateRowSource; } set { CheckDisposed(); _updateRowSource = value; } } /// <summary> /// Determines if the command is visible at design time. Defaults to True. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DesignOnly(true), Browsable(false), DefaultValue(true), EditorBrowsable(EditorBrowsableState.Never)] #endif public override bool DesignTimeVisible { get { CheckDisposed(); return _designTimeVisible; } set { CheckDisposed(); _designTimeVisible = value; #if !PLATFORM_COMPACTFRAMEWORK TypeDescriptor.Refresh(this); #endif } } /// <summary> /// Clones a command, including all its parameters /// </summary> /// <returns>A new SQLiteCommand with the same commandtext, connection and parameters</returns> public object Clone() { CheckDisposed(); return new SQLiteCommand(this); } } } |
Changes to System.Data.SQLite/SQLiteCommandBuilder.cs.
︙ | ︙ | |||
32 33 34 35 36 37 38 39 40 41 42 43 44 45 | public SQLiteCommandBuilder(SQLiteDataAdapter adp) { QuotePrefix = "["; QuoteSuffix = "]"; DataAdapter = adp; } /// <summary> /// Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema /// </summary> /// <param name="parameter">The parameter to use in applying custom behaviors to a row</param> /// <param name="row">The row to apply the parameter to</param> /// <param name="statementType">The type of statement</param> /// <param name="whereClause">Whether the application of the parameter is part of a WHERE clause</param> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 85 86 87 88 | public SQLiteCommandBuilder(SQLiteDataAdapter adp) { QuotePrefix = "["; QuoteSuffix = "]"; DataAdapter = adp; } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteCommandBuilder).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Minimal amount of parameter processing. Primarily sets the DbType for the parameter equal to the provider type in the schema /// </summary> /// <param name="parameter">The parameter to use in applying custom behaviors to a row</param> /// <param name="row">The row to apply the parameter to</param> /// <param name="statementType">The type of statement</param> /// <param name="whereClause">Whether the application of the parameter is part of a WHERE clause</param> |
︙ | ︙ | |||
102 103 104 105 106 107 108 | } /// <summary> /// Gets/sets the DataAdapter for this CommandBuilder /// </summary> public new SQLiteDataAdapter DataAdapter { | | | > > > > > > > > > > > > > > > > > > | 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 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 322 323 324 325 326 327 328 329 330 331 332 | } /// <summary> /// Gets/sets the DataAdapter for this CommandBuilder /// </summary> public new SQLiteDataAdapter DataAdapter { get { CheckDisposed(); return (SQLiteDataAdapter)base.DataAdapter; } set { CheckDisposed(); base.DataAdapter = value; } } /// <summary> /// Returns the automatically-generated SQLite command to delete rows from the database /// </summary> /// <returns></returns> public new SQLiteCommand GetDeleteCommand() { CheckDisposed(); return (SQLiteCommand)base.GetDeleteCommand(); } /// <summary> /// Returns the automatically-generated SQLite command to delete rows from the database /// </summary> /// <param name="useColumnsForParameterNames"></param> /// <returns></returns> public new SQLiteCommand GetDeleteCommand(bool useColumnsForParameterNames) { CheckDisposed(); return (SQLiteCommand)base.GetDeleteCommand(useColumnsForParameterNames); } /// <summary> /// Returns the automatically-generated SQLite command to update rows in the database /// </summary> /// <returns></returns> public new SQLiteCommand GetUpdateCommand() { CheckDisposed(); return (SQLiteCommand)base.GetUpdateCommand(); } /// <summary> /// Returns the automatically-generated SQLite command to update rows in the database /// </summary> /// <param name="useColumnsForParameterNames"></param> /// <returns></returns> public new SQLiteCommand GetUpdateCommand(bool useColumnsForParameterNames) { CheckDisposed(); return (SQLiteCommand)base.GetUpdateCommand(useColumnsForParameterNames); } /// <summary> /// Returns the automatically-generated SQLite command to insert rows into the database /// </summary> /// <returns></returns> public new SQLiteCommand GetInsertCommand() { CheckDisposed(); return (SQLiteCommand)base.GetInsertCommand(); } /// <summary> /// Returns the automatically-generated SQLite command to insert rows into the database /// </summary> /// <param name="useColumnsForParameterNames"></param> /// <returns></returns> public new SQLiteCommand GetInsertCommand(bool useColumnsForParameterNames) { CheckDisposed(); return (SQLiteCommand)base.GetInsertCommand(useColumnsForParameterNames); } /// <summary> /// Overridden to hide its property from the designer /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif public override CatalogLocation CatalogLocation { get { CheckDisposed(); return base.CatalogLocation; } set { CheckDisposed(); base.CatalogLocation = value; } } /// <summary> /// Overridden to hide its property from the designer /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif public override string CatalogSeparator { get { CheckDisposed(); return base.CatalogSeparator; } set { CheckDisposed(); base.CatalogSeparator = value; } } /// <summary> /// Overridden to hide its property from the designer /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif [DefaultValue("[")] public override string QuotePrefix { get { CheckDisposed(); return base.QuotePrefix; } set { CheckDisposed(); base.QuotePrefix = value; } } /// <summary> /// Overridden to hide its property from the designer /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif public override string QuoteSuffix { get { CheckDisposed(); return base.QuoteSuffix; } set { CheckDisposed(); base.QuoteSuffix = value; } } /// <summary> /// Places brackets around an identifier /// </summary> /// <param name="unquotedIdentifier">The identifier to quote</param> /// <returns>The bracketed identifier</returns> public override string QuoteIdentifier(string unquotedIdentifier) { CheckDisposed(); if (String.IsNullOrEmpty(QuotePrefix) || String.IsNullOrEmpty(QuoteSuffix) || String.IsNullOrEmpty(unquotedIdentifier)) return unquotedIdentifier; return QuotePrefix + unquotedIdentifier.Replace(QuoteSuffix, QuoteSuffix + QuoteSuffix) + QuoteSuffix; } /// <summary> /// Removes brackets around an identifier /// </summary> /// <param name="quotedIdentifier">The quoted (bracketed) identifier</param> /// <returns>The undecorated identifier</returns> public override string UnquoteIdentifier(string quotedIdentifier) { CheckDisposed(); if (String.IsNullOrEmpty(QuotePrefix) || String.IsNullOrEmpty(QuoteSuffix) || String.IsNullOrEmpty(quotedIdentifier)) return quotedIdentifier; if (quotedIdentifier.StartsWith(QuotePrefix, StringComparison.OrdinalIgnoreCase) == false || quotedIdentifier.EndsWith(QuoteSuffix, StringComparison.OrdinalIgnoreCase) == false) |
︙ | ︙ | |||
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif public override string SchemaSeparator { get { return base.SchemaSeparator; } set { base.SchemaSeparator = value; } } /// <summary> /// Override helper, which can help the base command builder choose the right keys for the given query /// </summary> | > > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 | #if !PLATFORM_COMPACTFRAMEWORK [Browsable(false)] #endif public override string SchemaSeparator { get { CheckDisposed(); return base.SchemaSeparator; } set { CheckDisposed(); base.SchemaSeparator = value; } } /// <summary> /// Override helper, which can help the base command builder choose the right keys for the given query /// </summary> |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteConnection.cs.
︙ | ︙ | |||
309 310 311 312 313 314 315 316 317 318 319 320 321 322 | } } } } } } #if PLATFORM_COMPACTFRAMEWORK /// <summary> /// Obsolete /// </summary> public override int ConnectionTimeout { get | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | } } } } } } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteConnection).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// Close(); disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #if PLATFORM_COMPACTFRAMEWORK /// <summary> /// Obsolete /// </summary> public override int ConnectionTimeout { get |
︙ | ︙ | |||
332 333 334 335 336 337 338 | /// </summary> /// <returns></returns> public object Clone() { return new SQLiteConnection(this); } | < < < < < < < < < < < < | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | /// </summary> /// <returns></returns> public object Clone() { return new SQLiteConnection(this); } /// <summary> /// Creates a database file. This just creates a zero-byte file which SQLite /// will turn into a database when the file is opened properly. /// </summary> /// <param name="databaseFileName">The file to create</param> static public void CreateFile(string databaseFileName) { |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteDataAdapter.cs.
︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | /// <param name="connectionString">A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.</param> public SQLiteDataAdapter(string commandText, string connectionString) { SQLiteConnection cnn = new SQLiteConnection(connectionString); SelectCommand = new SQLiteCommand(commandText, cnn); } /// <summary> /// Row updating event handler /// </summary> public event EventHandler<RowUpdatingEventArgs> RowUpdating { add { #if !PLATFORM_COMPACTFRAMEWORK EventHandler<RowUpdatingEventArgs> previous = (EventHandler<RowUpdatingEventArgs>)base.Events[_updatingEventPH]; if ((previous != null) && (value.Target is DbCommandBuilder)) { EventHandler<RowUpdatingEventArgs> handler = (EventHandler<RowUpdatingEventArgs>)FindBuilder(previous); if (handler != null) { base.Events.RemoveHandler(_updatingEventPH, handler); } } #endif base.Events.AddHandler(_updatingEventPH, value); } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | /// <param name="connectionString">A connection string suitable for passing to a new SQLiteConnection, which is associated with the select command.</param> public SQLiteDataAdapter(string commandText, string connectionString) { SQLiteConnection cnn = new SQLiteConnection(connectionString); SelectCommand = new SQLiteCommand(commandText, cnn); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteDataAdapter).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Row updating event handler /// </summary> public event EventHandler<RowUpdatingEventArgs> RowUpdating { add { CheckDisposed(); #if !PLATFORM_COMPACTFRAMEWORK EventHandler<RowUpdatingEventArgs> previous = (EventHandler<RowUpdatingEventArgs>)base.Events[_updatingEventPH]; if ((previous != null) && (value.Target is DbCommandBuilder)) { EventHandler<RowUpdatingEventArgs> handler = (EventHandler<RowUpdatingEventArgs>)FindBuilder(previous); if (handler != null) { base.Events.RemoveHandler(_updatingEventPH, handler); } } #endif base.Events.AddHandler(_updatingEventPH, value); } remove { CheckDisposed(); base.Events.RemoveHandler(_updatingEventPH, value); } } #if !PLATFORM_COMPACTFRAMEWORK internal static Delegate FindBuilder(MulticastDelegate mcd) { if (mcd != null) { |
︙ | ︙ | |||
106 107 108 109 110 111 112 | #endif /// <summary> /// Row updated event handler /// </summary> public event EventHandler<RowUpdatedEventArgs> RowUpdated { | | | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | #endif /// <summary> /// Row updated event handler /// </summary> public event EventHandler<RowUpdatedEventArgs> RowUpdated { add { CheckDisposed(); base.Events.AddHandler(_updatedEventPH, value); } remove { CheckDisposed(); base.Events.RemoveHandler(_updatedEventPH, value); } } /// <summary> /// Raised by the underlying DbDataAdapter when a row is being updated /// </summary> /// <param name="value">The event's specifics</param> protected override void OnRowUpdating(RowUpdatingEventArgs value) |
︙ | ︙ | |||
142 143 144 145 146 147 148 | /// Gets/sets the select command for this DataAdapter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, 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")] #endif public new SQLiteCommand SelectCommand { | | | | | | | | | | 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 | /// Gets/sets the select command for this DataAdapter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, 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")] #endif public new SQLiteCommand SelectCommand { get { CheckDisposed(); return (SQLiteCommand)base.SelectCommand; } set { CheckDisposed(); base.SelectCommand = value; } } /// <summary> /// Gets/sets the insert command for this DataAdapter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, 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")] #endif public new SQLiteCommand InsertCommand { get { CheckDisposed(); return (SQLiteCommand)base.InsertCommand; } set { CheckDisposed(); base.InsertCommand = value; } } /// <summary> /// Gets/sets the update command for this DataAdapter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, 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")] #endif public new SQLiteCommand UpdateCommand { get { CheckDisposed(); return (SQLiteCommand)base.UpdateCommand; } set { CheckDisposed(); base.UpdateCommand = value; } } /// <summary> /// Gets/sets the delete command for this DataAdapter /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [DefaultValue((string)null), Editor("Microsoft.VSDesigner.Data.Design.DBCommandEditor, 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")] #endif public new SQLiteCommand DeleteCommand { get { CheckDisposed(); return (SQLiteCommand)base.DeleteCommand; } set { CheckDisposed(); base.DeleteCommand = value; } } } } |
Changes to System.Data.SQLite/SQLiteDataReader.cs.
︙ | ︙ | |||
62 63 64 65 66 67 68 | internal bool _disposeCommand; /// <summary> /// If set, then raise an exception when the object is accessed after being disposed. /// </summary> internal bool _throwOnDisposed; | < < < < < | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | internal bool _disposeCommand; /// <summary> /// If set, then raise an exception when the object is accessed after being disposed. /// </summary> internal bool _throwOnDisposed; /// <summary> /// An array of rowid's for the active statement if CommandBehavior.KeyInfo is specified /// </summary> private SQLiteKeyReader _keyInfo; /// <summary> /// Matches the version of the connection. |
︙ | ︙ | |||
104 105 106 107 108 109 110 | _activeStatementIndex = -1; _rowsAffected = -1; if (_command != null) NextResult(); } | > | > > > > > > | > > > > > > > > > > > > > > > > > | | | | < | > | > > > | > > > > > > > > > > > | 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | _activeStatementIndex = -1; _rowsAffected = -1; if (_command != null) NextResult(); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed && _throwOnDisposed) throw new ObjectDisposedException(typeof(SQLiteDataReader).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Dispose of all resources used by this datareader. /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// // // NOTE: Fix for ticket [e1b2e0f769], do NOT throw exceptions // while we are being disposed. // _throwOnDisposed = false; disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// internal void Cancel() { _version = 0; } /// <summary> /// Closes the datareader, potentially closing the connection as well if CommandBehavior.CloseConnection was specified. /// </summary> public override void Close() { CheckDisposed(); try { if (_command != null) { try { try |
︙ | ︙ | |||
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | /// <summary> /// Enumerator support /// </summary> /// <returns>Returns a DbEnumerator object.</returns> public override Collections.IEnumerator GetEnumerator() { return new DbEnumerator(this, ((_commandBehavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)); } /// <summary> /// Not implemented. Returns 0 /// </summary> public override int Depth { get { CheckClosed(); return 0; } } /// <summary> /// Returns the number of columns in the current resultset /// </summary> public override int FieldCount { get { CheckClosed(); if (_keyInfo == null) return _fieldCount; return _fieldCount + _keyInfo.Count; } } /// <summary> /// Returns the number of visible fielsd in the current resultset /// </summary> public override int VisibleFieldCount { get { CheckClosed(); return _fieldCount; } } /// <summary> /// SQLite is inherently un-typed. All datatypes in SQLite are natively strings. The definition of the columns of a table | > > > > > | 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | /// <summary> /// Enumerator support /// </summary> /// <returns>Returns a DbEnumerator object.</returns> public override Collections.IEnumerator GetEnumerator() { CheckDisposed(); return new DbEnumerator(this, ((_commandBehavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)); } /// <summary> /// Not implemented. Returns 0 /// </summary> public override int Depth { get { CheckDisposed(); CheckClosed(); return 0; } } /// <summary> /// Returns the number of columns in the current resultset /// </summary> public override int FieldCount { get { CheckDisposed(); CheckClosed(); if (_keyInfo == null) return _fieldCount; return _fieldCount + _keyInfo.Count; } } /// <summary> /// Returns the number of visible fielsd in the current resultset /// </summary> public override int VisibleFieldCount { get { CheckDisposed(); CheckClosed(); return _fieldCount; } } /// <summary> /// SQLite is inherently un-typed. All datatypes in SQLite are natively strings. The definition of the columns of a table |
︙ | ︙ | |||
273 274 275 276 277 278 279 280 281 282 283 284 285 286 | /// </returns> /// <param name="i">The index of the column to type-check</param> /// <param name="typ">The type we want to get out of the column</param> private TypeAffinity VerifyType(int i, DbType typ) { CheckClosed(); CheckValidRow(); TypeAffinity affinity = GetSQLiteType(i).Affinity; switch (affinity) { case TypeAffinity.Int64: if (typ == DbType.Int16) return affinity; if (typ == DbType.Int32) return affinity; | > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | /// </returns> /// <param name="i">The index of the column to type-check</param> /// <param name="typ">The type we want to get out of the column</param> private TypeAffinity VerifyType(int i, DbType typ) { CheckClosed(); CheckValidRow(); TypeAffinity affinity = GetSQLiteType(i).Affinity; switch (affinity) { case TypeAffinity.Int64: if (typ == DbType.Int16) return affinity; if (typ == DbType.Int32) return affinity; |
︙ | ︙ | |||
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | /// <summary> /// Retrieves the column as a boolean value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>bool</returns> public override bool GetBoolean(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetBoolean(i - VisibleFieldCount); VerifyType(i, DbType.Boolean); return Convert.ToBoolean(GetValue(i), CultureInfo.CurrentCulture); } /// <summary> /// Retrieves the column as a single byte value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>byte</returns> public override byte GetByte(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetByte(i - VisibleFieldCount); VerifyType(i, DbType.Byte); return Convert.ToByte(_activeStatement._sql.GetInt32(_activeStatement, i)); } | > > > > | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | /// <summary> /// Retrieves the column as a boolean value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>bool</returns> public override bool GetBoolean(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetBoolean(i - VisibleFieldCount); VerifyType(i, DbType.Boolean); return Convert.ToBoolean(GetValue(i), CultureInfo.CurrentCulture); } /// <summary> /// Retrieves the column as a single byte value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>byte</returns> public override byte GetByte(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetByte(i - VisibleFieldCount); VerifyType(i, DbType.Byte); return Convert.ToByte(_activeStatement._sql.GetInt32(_activeStatement, i)); } |
︙ | ︙ | |||
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | /// <param name="length">The number of bytes to retrieve</param> /// <returns>The actual number of bytes written into the array</returns> /// <remarks> /// To determine the number of bytes in the column, pass a null value for the buffer. The total length will be returned. /// </remarks> public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetBytes(i - VisibleFieldCount, fieldOffset, buffer, bufferoffset, length); VerifyType(i, DbType.Binary); return _activeStatement._sql.GetBytes(_activeStatement, i, (int)fieldOffset, buffer, bufferoffset, length); } /// <summary> /// Returns the column as a single character /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>char</returns> public override char GetChar(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetChar(i - VisibleFieldCount); VerifyType(i, DbType.SByte); return Convert.ToChar(_activeStatement._sql.GetInt32(_activeStatement, i)); } | > > > > | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | /// <param name="length">The number of bytes to retrieve</param> /// <returns>The actual number of bytes written into the array</returns> /// <remarks> /// To determine the number of bytes in the column, pass a null value for the buffer. The total length will be returned. /// </remarks> public override long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetBytes(i - VisibleFieldCount, fieldOffset, buffer, bufferoffset, length); VerifyType(i, DbType.Binary); return _activeStatement._sql.GetBytes(_activeStatement, i, (int)fieldOffset, buffer, bufferoffset, length); } /// <summary> /// Returns the column as a single character /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>char</returns> public override char GetChar(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetChar(i - VisibleFieldCount); VerifyType(i, DbType.SByte); return Convert.ToChar(_activeStatement._sql.GetInt32(_activeStatement, i)); } |
︙ | ︙ | |||
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | /// <param name="length">The number of bytes to retrieve</param> /// <returns>The actual number of characters written into the array</returns> /// <remarks> /// To determine the number of characters in the column, pass a null value for the buffer. The total length will be returned. /// </remarks> public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetChars(i - VisibleFieldCount, fieldoffset, buffer, bufferoffset, length); VerifyType(i, DbType.String); return _activeStatement._sql.GetChars(_activeStatement, i, (int)fieldoffset, buffer, bufferoffset, length); } /// <summary> /// Retrieves the name of the back-end datatype of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetDataTypeName(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDataTypeName(i - VisibleFieldCount); SQLiteType typ = GetSQLiteType(i); if (typ.Type == DbType.Object) return SQLiteConvert.SQLiteTypeToType(typ).Name; return _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity); } /// <summary> /// Retrieve the column as a date/time value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>DateTime</returns> public override DateTime GetDateTime(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDateTime(i - VisibleFieldCount); VerifyType(i, DbType.DateTime); return _activeStatement._sql.GetDateTime(_activeStatement, i); } /// <summary> /// Retrieve the column as a decimal value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>decimal</returns> public override decimal GetDecimal(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDecimal(i - VisibleFieldCount); VerifyType(i, DbType.Decimal); return Decimal.Parse(_activeStatement._sql.GetText(_activeStatement, i), NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture); } /// <summary> /// Returns the column as a double /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>double</returns> public override double GetDouble(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDouble(i - VisibleFieldCount); VerifyType(i, DbType.Double); return _activeStatement._sql.GetDouble(_activeStatement, i); } /// <summary> /// Returns the .NET type of a given column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Type</returns> public override Type GetFieldType(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetFieldType(i - VisibleFieldCount); return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i)); } /// <summary> /// Returns a column as a float value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>float</returns> public override float GetFloat(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetFloat(i - VisibleFieldCount); VerifyType(i, DbType.Single); return Convert.ToSingle(_activeStatement._sql.GetDouble(_activeStatement, i)); } /// <summary> /// Returns the column as a Guid /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Guid</returns> public override Guid GetGuid(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetGuid(i - VisibleFieldCount); TypeAffinity affinity = VerifyType(i, DbType.Guid); if (affinity == TypeAffinity.Blob) { byte[] buffer = new byte[16]; | > > > > > > > > > > > > > > > > | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 | /// <param name="length">The number of bytes to retrieve</param> /// <returns>The actual number of characters written into the array</returns> /// <remarks> /// To determine the number of characters in the column, pass a null value for the buffer. The total length will be returned. /// </remarks> public override long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetChars(i - VisibleFieldCount, fieldoffset, buffer, bufferoffset, length); VerifyType(i, DbType.String); return _activeStatement._sql.GetChars(_activeStatement, i, (int)fieldoffset, buffer, bufferoffset, length); } /// <summary> /// Retrieves the name of the back-end datatype of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetDataTypeName(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDataTypeName(i - VisibleFieldCount); SQLiteType typ = GetSQLiteType(i); if (typ.Type == DbType.Object) return SQLiteConvert.SQLiteTypeToType(typ).Name; return _activeStatement._sql.ColumnType(_activeStatement, i, out typ.Affinity); } /// <summary> /// Retrieve the column as a date/time value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>DateTime</returns> public override DateTime GetDateTime(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDateTime(i - VisibleFieldCount); VerifyType(i, DbType.DateTime); return _activeStatement._sql.GetDateTime(_activeStatement, i); } /// <summary> /// Retrieve the column as a decimal value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>decimal</returns> public override decimal GetDecimal(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDecimal(i - VisibleFieldCount); VerifyType(i, DbType.Decimal); return Decimal.Parse(_activeStatement._sql.GetText(_activeStatement, i), NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent | NumberStyles.AllowLeadingSign, CultureInfo.InvariantCulture); } /// <summary> /// Returns the column as a double /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>double</returns> public override double GetDouble(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetDouble(i - VisibleFieldCount); VerifyType(i, DbType.Double); return _activeStatement._sql.GetDouble(_activeStatement, i); } /// <summary> /// Returns the .NET type of a given column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Type</returns> public override Type GetFieldType(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetFieldType(i - VisibleFieldCount); return SQLiteConvert.SQLiteTypeToType(GetSQLiteType(i)); } /// <summary> /// Returns a column as a float value /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>float</returns> public override float GetFloat(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetFloat(i - VisibleFieldCount); VerifyType(i, DbType.Single); return Convert.ToSingle(_activeStatement._sql.GetDouble(_activeStatement, i)); } /// <summary> /// Returns the column as a Guid /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Guid</returns> public override Guid GetGuid(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetGuid(i - VisibleFieldCount); TypeAffinity affinity = VerifyType(i, DbType.Guid); if (affinity == TypeAffinity.Blob) { byte[] buffer = new byte[16]; |
︙ | ︙ | |||
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | /// <summary> /// Returns the column as a short /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int16</returns> public override Int16 GetInt16(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt16(i - VisibleFieldCount); VerifyType(i, DbType.Int16); return Convert.ToInt16(_activeStatement._sql.GetInt32(_activeStatement, i)); } /// <summary> /// Retrieves the column as an int /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int32</returns> public override Int32 GetInt32(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt32(i - VisibleFieldCount); VerifyType(i, DbType.Int32); return _activeStatement._sql.GetInt32(_activeStatement, i); } /// <summary> /// Retrieves the column as a long /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int64</returns> public override Int64 GetInt64(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt64(i - VisibleFieldCount); VerifyType(i, DbType.Int64); return _activeStatement._sql.GetInt64(_activeStatement, i); } /// <summary> /// Retrieves the name of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetName(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetName(i - VisibleFieldCount); return _activeStatement._sql.ColumnName(_activeStatement, i); } /// <summary> /// Retrieves the i of a column, given its name /// </summary> /// <param name="name">The name of the column to retrieve</param> /// <returns>The int i of the column</returns> public override int GetOrdinal(string name) { CheckClosed(); int r = _activeStatement._sql.ColumnIndex(_activeStatement, name); if (r == -1 && _keyInfo != null) { r = _keyInfo.GetOrdinal(name); if (r > -1) r += VisibleFieldCount; } return r; } /// <summary> /// Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done /// to gather the necessary information so it can be represented in an ADO.NET manner. /// </summary> /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns> public override DataTable GetSchemaTable() { return GetSchemaTable(true, false); } private class ColumnParent : IEqualityComparer<ColumnParent> { public string DatabaseName; public string TableName; | > > > > > > > > > > > | 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | /// <summary> /// Returns the column as a short /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int16</returns> public override Int16 GetInt16(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt16(i - VisibleFieldCount); VerifyType(i, DbType.Int16); return Convert.ToInt16(_activeStatement._sql.GetInt32(_activeStatement, i)); } /// <summary> /// Retrieves the column as an int /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int32</returns> public override Int32 GetInt32(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt32(i - VisibleFieldCount); VerifyType(i, DbType.Int32); return _activeStatement._sql.GetInt32(_activeStatement, i); } /// <summary> /// Retrieves the column as a long /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>Int64</returns> public override Int64 GetInt64(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetInt64(i - VisibleFieldCount); VerifyType(i, DbType.Int64); return _activeStatement._sql.GetInt64(_activeStatement, i); } /// <summary> /// Retrieves the name of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetName(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetName(i - VisibleFieldCount); return _activeStatement._sql.ColumnName(_activeStatement, i); } /// <summary> /// Retrieves the i of a column, given its name /// </summary> /// <param name="name">The name of the column to retrieve</param> /// <returns>The int i of the column</returns> public override int GetOrdinal(string name) { CheckDisposed(); CheckClosed(); int r = _activeStatement._sql.ColumnIndex(_activeStatement, name); if (r == -1 && _keyInfo != null) { r = _keyInfo.GetOrdinal(name); if (r > -1) r += VisibleFieldCount; } return r; } /// <summary> /// Schema information in SQLite is difficult to map into .NET conventions, so a lot of work must be done /// to gather the necessary information so it can be represented in an ADO.NET manner. /// </summary> /// <returns>Returns a DataTable containing the schema information for the active SELECT statement being processed.</returns> public override DataTable GetSchemaTable() { CheckDisposed(); return GetSchemaTable(true, false); } private class ColumnParent : IEqualityComparer<ColumnParent> { public string DatabaseName; public string TableName; |
︙ | ︙ | |||
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 | /// <summary> /// Retrieves the column as a string /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetString(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetString(i - VisibleFieldCount); VerifyType(i, DbType.String); return _activeStatement._sql.GetText(_activeStatement, i); } /// <summary> /// Retrieves the column as an object corresponding to the underlying datatype of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>object</returns> public override object GetValue(int i) { if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetValue(i - VisibleFieldCount); SQLiteType typ = GetSQLiteType(i); return _activeStatement._sql.GetValue(_activeStatement, i, typ); } /// <summary> /// Retreives the values of multiple columns, up to the size of the supplied array /// </summary> /// <param name="values">The array to fill with values from the columns in the current resultset</param> /// <returns>The number of columns retrieved</returns> public override int GetValues(object[] values) { int nMax = FieldCount; if (values.Length < nMax) nMax = values.Length; for (int n = 0; n < nMax; n++) { values[n] = GetValue(n); } return nMax; } /// <summary> /// Returns True if the resultset has rows that can be fetched /// </summary> public override bool HasRows { get { CheckClosed(); return (_readingState != 1); } } /// <summary> /// Returns True if the data reader is closed /// </summary> public override bool IsClosed { | > > > > > > > | > > > | 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 | /// <summary> /// Retrieves the column as a string /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>string</returns> public override string GetString(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetString(i - VisibleFieldCount); VerifyType(i, DbType.String); return _activeStatement._sql.GetText(_activeStatement, i); } /// <summary> /// Retrieves the column as an object corresponding to the underlying datatype of the column /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>object</returns> public override object GetValue(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.GetValue(i - VisibleFieldCount); SQLiteType typ = GetSQLiteType(i); return _activeStatement._sql.GetValue(_activeStatement, i, typ); } /// <summary> /// Retreives the values of multiple columns, up to the size of the supplied array /// </summary> /// <param name="values">The array to fill with values from the columns in the current resultset</param> /// <returns>The number of columns retrieved</returns> public override int GetValues(object[] values) { CheckDisposed(); int nMax = FieldCount; if (values.Length < nMax) nMax = values.Length; for (int n = 0; n < nMax; n++) { values[n] = GetValue(n); } return nMax; } /// <summary> /// Returns True if the resultset has rows that can be fetched /// </summary> public override bool HasRows { get { CheckDisposed(); CheckClosed(); return (_readingState != 1); } } /// <summary> /// Returns True if the data reader is closed /// </summary> public override bool IsClosed { get { CheckDisposed(); return (_command == null); } } /// <summary> /// Returns True if the specified column is null /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>True or False</returns> public override bool IsDBNull(int i) { CheckDisposed(); if (i >= VisibleFieldCount && _keyInfo != null) return _keyInfo.IsDBNull(i - VisibleFieldCount); return _activeStatement._sql.IsNull(_activeStatement, i); } /// <summary> /// Moves to the next resultset in multiple row-returning SQL command. /// </summary> /// <returns>True if the command was successful and a new resultset is available, False otherwise.</returns> public override bool NextResult() { CheckDisposed(); CheckClosed(); SQLiteStatement stmt = null; int fieldCount; while (true) { |
︙ | ︙ | |||
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 | /// <summary> /// Reads the next row from the resultset /// </summary> /// <returns>True if a new row was successfully loaded and is ready for processing</returns> public override bool Read() { CheckClosed(); if (_readingState == -1) // First step was already done at the NextResult() level, so don't step again, just return true. { _readingState = 0; return true; } | > | 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 | /// <summary> /// Reads the next row from the resultset /// </summary> /// <returns>True if a new row was successfully loaded and is ready for processing</returns> public override bool Read() { CheckDisposed(); CheckClosed(); if (_readingState == -1) // First step was already done at the NextResult() level, so don't step again, just return true. { _readingState = 0; return true; } |
︙ | ︙ | |||
1167 1168 1169 1170 1171 1172 1173 | } /// <summary> /// Retrieve the count of records affected by an update/insert command. Only valid once the data reader is closed! /// </summary> public override int RecordsAffected { | | | | | 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 | } /// <summary> /// Retrieve the count of records affected by an update/insert command. Only valid once the data reader is closed! /// </summary> public override int RecordsAffected { get { CheckDisposed(); return (_rowsAffected < 0) ? 0 : _rowsAffected; } } /// <summary> /// Indexer to retrieve data from a column given its name /// </summary> /// <param name="name">The name of the column to retrieve data for</param> /// <returns>The value contained in the column</returns> public override object this[string name] { get { CheckDisposed(); return GetValue(GetOrdinal(name)); } } /// <summary> /// Indexer to retrieve data from a column given its i /// </summary> /// <param name="i">The index of the column to retrieve</param> /// <returns>The value contained in the column</returns> public override object this[int i] { get { CheckDisposed(); return GetValue(i); } } private void LoadKeyInfo() { if (_keyInfo != null) _keyInfo.Dispose(); _keyInfo = new SQLiteKeyReader(_command.Connection, this, _activeStatement); } } } |
Changes to System.Data.SQLite/SQLiteEnlistment.cs.
1 2 3 4 5 6 7 8 9 10 11 12 | /******************************************************** * 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! ********************************************************/ #if !PLATFORM_COMPACTFRAMEWORK namespace System.Data.SQLite { using System.Transactions; | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | /******************************************************** * 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! ********************************************************/ #if !PLATFORM_COMPACTFRAMEWORK namespace System.Data.SQLite { using System.Transactions; internal class SQLiteEnlistment : IEnlistmentNotification, IDisposable { internal SQLiteTransaction _transaction; internal Transaction _scope; internal bool _disposeConnection; internal SQLiteEnlistment(SQLiteConnection cnn, Transaction scope) { _transaction = cnn.BeginTransaction(); _scope = scope; _scope.EnlistVolatile(this, System.Transactions.EnlistmentOptions.None); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteEnlistment).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// if (_transaction != null) { _transaction.Dispose(); _transaction = null; } if (_scope != null) { // _scope.Dispose(); // NOTE: Not "owned" by us. _scope = null; } } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteEnlistment() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// private void Cleanup(SQLiteConnection cnn) { if (_disposeConnection) cnn.Dispose(); _transaction = null; _scope = null; } #region IEnlistmentNotification Members public void Commit(Enlistment enlistment) { CheckDisposed(); SQLiteConnection cnn = _transaction.Connection; cnn._enlistment = null; try { _transaction.IsValid(true); _transaction.Connection._transactionLevel = 1; _transaction.Commit(); enlistment.Done(); } finally { Cleanup(cnn); } } public void InDoubt(Enlistment enlistment) { CheckDisposed(); enlistment.Done(); } public void Prepare(PreparingEnlistment preparingEnlistment) { CheckDisposed(); if (_transaction.IsValid(false) == false) preparingEnlistment.ForceRollback(); else preparingEnlistment.Prepared(); } public void Rollback(Enlistment enlistment) { CheckDisposed(); SQLiteConnection cnn = _transaction.Connection; cnn._enlistment = null; try { _transaction.Rollback(); enlistment.Done(); |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteFactory.cs.
︙ | ︙ | |||
10 11 12 13 14 15 16 | using System; using System.Data.Common; #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// SQLite implementation of DbProviderFactory. /// </summary> | | < < < < < < < < < < < < > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | using System; using System.Data.Common; #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// SQLite implementation of DbProviderFactory. /// </summary> public sealed partial class SQLiteFactory : DbProviderFactory, IDisposable { /// <overloads> /// Constructs a new SQLiteFactory object /// </overloads> /// <summary> /// Default constructor /// </summary> public SQLiteFactory() { // // NOTE: Do nothing here now. All the logging setup related code has // been moved to the new SQLiteLog static class. // } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteFactory).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// private void Dispose(bool disposing) { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteFactory() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// This event is raised whenever SQLite raises a logging event. /// Note that this should be set as one of the first things in the /// application. This event is provided for backward compatibility only. /// New code should use the SQLiteLog class instead. /// </summary> public event SQLiteLogEventHandler Log { add { CheckDisposed(); SQLiteLog.Log += value; } remove { CheckDisposed(); SQLiteLog.Log -= value; } } /// <summary> /// Static instance member which returns an instanced SQLiteFactory class. /// </summary> public static readonly SQLiteFactory Instance = new SQLiteFactory(); /// <summary> /// Returns a new SQLiteCommand object. /// </summary> /// <returns>A SQLiteCommand object.</returns> public override DbCommand CreateCommand() { CheckDisposed(); return new SQLiteCommand(); } /// <summary> /// Returns a new SQLiteCommandBuilder object. /// </summary> /// <returns>A SQLiteCommandBuilder object.</returns> public override DbCommandBuilder CreateCommandBuilder() { CheckDisposed(); return new SQLiteCommandBuilder(); } /// <summary> /// Creates a new SQLiteConnection. /// </summary> /// <returns>A SQLiteConnection object.</returns> public override DbConnection CreateConnection() { CheckDisposed(); return new SQLiteConnection(); } /// <summary> /// Creates a new SQLiteConnectionStringBuilder. /// </summary> /// <returns>A SQLiteConnectionStringBuilder object.</returns> public override DbConnectionStringBuilder CreateConnectionStringBuilder() { CheckDisposed(); return new SQLiteConnectionStringBuilder(); } /// <summary> /// Creates a new SQLiteDataAdapter. /// </summary> /// <returns>A SQLiteDataAdapter object.</returns> public override DbDataAdapter CreateDataAdapter() { CheckDisposed(); return new SQLiteDataAdapter(); } /// <summary> /// Creates a new SQLiteParameter. /// </summary> /// <returns>A SQLiteParameter object.</returns> public override DbParameter CreateParameter() { CheckDisposed(); return new SQLiteParameter(); } } #endif } |
Changes to System.Data.SQLite/SQLiteFunction.cs.
︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | /// Internal constructor, initializes the function's internal variables. /// </summary> protected SQLiteFunction() { _contextDataList = new Dictionary<long, AggregateData>(); } /// <summary> /// Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert /// strings and DateTime's into the current connection's encoding schema. /// </summary> public SQLiteConvert SQLiteConvert { get { return _base; } } /// <summary> /// Scalar functions override this method to do their magic. /// </summary> /// <remarks> /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available /// to force them into a certain type. Therefore the only types you will ever see as parameters are /// DBNull.Value, Int64, Double, String or byte[] array. /// </remarks> /// <param name="args">The arguments for the command to process</param> /// <returns>You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or /// you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, /// just return it!</returns> public virtual object Invoke(object[] args) { return null; } /// <summary> /// Aggregate functions override this method to do their magic. /// </summary> /// <remarks> /// Typically you'll be updating whatever you've placed in the contextData field and returning as quickly as possible. /// </remarks> /// <param name="args">The arguments for the command to process</param> /// <param name="stepNumber">The 1-based step number. This is incrememted each time the step method is called.</param> /// <param name="contextData">A placeholder for implementers to store contextual data pertaining to the current context.</param> public virtual void Step(object[] args, int stepNumber, ref object contextData) { } /// <summary> /// Aggregate functions override this method to finish their aggregate processing. /// </summary> /// <remarks> /// If you implemented your aggregate function properly, /// you've been recording and keeping track of your data in the contextData object provided, and now at this stage you should have /// all the information you need in there to figure out what to return. /// NOTE: It is possible to arrive here without receiving a previous call to Step(), in which case the contextData will /// be null. This can happen when no rows were returned. You can either return null, or 0 or some other custom return value /// if that is the case. /// </remarks> /// <param name="contextData">Your own assigned contextData, provided for you so you can return your final results.</param> /// <returns>You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or /// you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, /// just return it! /// </returns> public virtual object Final(object contextData) { return null; } /// <summary> /// User-defined collation sequences override this method to provide a custom string sorting algorithm. /// </summary> /// <param name="param1">The first string to compare</param> /// <param name="param2">The second strnig to compare</param> /// <returns>1 if param1 is greater than param2, 0 if they are equal, or -1 if param1 is less than param2</returns> public virtual int Compare(string param1, string param2) { return 0; } /// <summary> /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to. /// </summary> /// <remarks> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | /// Internal constructor, initializes the function's internal variables. /// </summary> protected SQLiteFunction() { _contextDataList = new Dictionary<long, AggregateData>(); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members /// <summary> /// Disposes of any active contextData variables that were not automatically cleaned up. Sometimes this can happen if /// someone closes the connection while a DataReader is open. /// </summary> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteFunction).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Placeholder for a user-defined disposal routine /// </summary> /// <param name="disposing">True if the object is being disposed explicitly</param> protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// IDisposable disp; foreach (KeyValuePair<long, AggregateData> kv in _contextDataList) { disp = kv.Value._data as IDisposable; if (disp != null) disp.Dispose(); } _contextDataList.Clear(); _InvokeFunc = null; _StepFunc = null; _FinalFunc = null; _CompareFunc = null; _base = null; _contextDataList = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteFunction() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Returns a reference to the underlying connection's SQLiteConvert class, which can be used to convert /// strings and DateTime's into the current connection's encoding schema. /// </summary> public SQLiteConvert SQLiteConvert { get { CheckDisposed(); return _base; } } /// <summary> /// Scalar functions override this method to do their magic. /// </summary> /// <remarks> /// Parameters passed to functions have only an affinity for a certain data type, there is no underlying schema available /// to force them into a certain type. Therefore the only types you will ever see as parameters are /// DBNull.Value, Int64, Double, String or byte[] array. /// </remarks> /// <param name="args">The arguments for the command to process</param> /// <returns>You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or /// you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, /// just return it!</returns> public virtual object Invoke(object[] args) { CheckDisposed(); return null; } /// <summary> /// Aggregate functions override this method to do their magic. /// </summary> /// <remarks> /// Typically you'll be updating whatever you've placed in the contextData field and returning as quickly as possible. /// </remarks> /// <param name="args">The arguments for the command to process</param> /// <param name="stepNumber">The 1-based step number. This is incrememted each time the step method is called.</param> /// <param name="contextData">A placeholder for implementers to store contextual data pertaining to the current context.</param> public virtual void Step(object[] args, int stepNumber, ref object contextData) { CheckDisposed(); } /// <summary> /// Aggregate functions override this method to finish their aggregate processing. /// </summary> /// <remarks> /// If you implemented your aggregate function properly, /// you've been recording and keeping track of your data in the contextData object provided, and now at this stage you should have /// all the information you need in there to figure out what to return. /// NOTE: It is possible to arrive here without receiving a previous call to Step(), in which case the contextData will /// be null. This can happen when no rows were returned. You can either return null, or 0 or some other custom return value /// if that is the case. /// </remarks> /// <param name="contextData">Your own assigned contextData, provided for you so you can return your final results.</param> /// <returns>You may return most simple types as a return value, null or DBNull.Value to return null, DateTime, or /// you may return an Exception-derived class if you wish to return an error to SQLite. Do not actually throw the error, /// just return it! /// </returns> public virtual object Final(object contextData) { CheckDisposed(); return null; } /// <summary> /// User-defined collation sequences override this method to provide a custom string sorting algorithm. /// </summary> /// <param name="param1">The first string to compare</param> /// <param name="param2">The second strnig to compare</param> /// <returns>1 if param1 is greater than param2, 0 if they are equal, or -1 if param1 is less than param2</returns> public virtual int Compare(string param1, string param2) { CheckDisposed(); return 0; } /// <summary> /// Converts an IntPtr array of context arguments to an object array containing the resolved parameters the pointers point to. /// </summary> /// <remarks> |
︙ | ︙ | |||
214 215 216 217 218 219 220 | } /// <summary> /// Takes the return value from Invoke() and Final() and figures out how to return it to SQLite's context. /// </summary> /// <param name="context">The context the return value applies to</param> /// <param name="returnValue">The parameter to return to SQLite</param> | | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 | } /// <summary> /// Takes the return value from Invoke() and Final() and figures out how to return it to SQLite's context. /// </summary> /// <param name="context">The context the return value applies to</param> /// <param name="returnValue">The parameter to return to SQLite</param> private void SetReturnValue(IntPtr context, object returnValue) { if (returnValue == null || returnValue == DBNull.Value) { _base.ReturnNull(context); return; } |
︙ | ︙ | |||
347 348 349 350 351 352 353 | _context = context; SetReturnValue(context, Final(obj)); IDisposable disp = obj as IDisposable; if (disp != null) disp.Dispose(); } | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | _context = context; SetReturnValue(context, Final(obj)); IDisposable disp = obj as IDisposable; if (disp != null) disp.Dispose(); } /// <summary> /// Using reflection, enumerate all assemblies in the current appdomain looking for classes that /// have a SQLiteFunctionAttribute attribute, and registering them accordingly. /// </summary> #if !PLATFORM_COMPACTFRAMEWORK [Security.Permissions.FileIOPermission(Security.Permissions.SecurityAction.Assert, AllFiles = Security.Permissions.FileIOPermissionAccess.PathDiscovery)] #endif |
︙ | ︙ | |||
536 537 538 539 540 541 542 543 544 545 546 547 548 549 | /// Obtains the collating sequence in effect for the given function. /// </summary> /// <returns></returns> protected CollationSequence GetCollationSequence() { return _base.GetCollationSequence(this, _context); } } /// <summary> /// The type of user-defined function to declare /// </summary> public enum FunctionType { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | /// Obtains the collating sequence in effect for the given function. /// </summary> /// <returns></returns> protected CollationSequence GetCollationSequence() { return _base.GetCollationSequence(this, _context); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteFunctionEx).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// protected override void Dispose(bool disposing) { try { if (!disposed) { //if (disposing) //{ // //////////////////////////////////// // // dispose managed resources here... // //////////////////////////////////// //} ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion } /// <summary> /// The type of user-defined function to declare /// </summary> public enum FunctionType { |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteKeyReader.cs.
︙ | ︙ | |||
41 42 43 44 45 46 47 | } /// <summary> /// A single sub-query for a given table/database. /// </summary> private sealed class KeyQuery : IDisposable { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > > > > > > > > > > > > > > > > > | 41 42 43 44 45 46 47 48 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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | } /// <summary> /// A single sub-query for a given table/database. /// </summary> private sealed class KeyQuery : IDisposable { private SQLiteCommand _command; internal SQLiteDataReader _reader; internal KeyQuery(SQLiteConnection cnn, string database, string table, params string[] columns) { using (SQLiteCommandBuilder builder = new SQLiteCommandBuilder()) { _command = cnn.CreateCommand(); for (int n = 0; n < columns.Length; n++) { columns[n] = builder.QuoteIdentifier(columns[n]); } } _command.CommandText = String.Format(CultureInfo.InvariantCulture, "SELECT {0} FROM [{1}].[{2}] WHERE ROWID = ?", String.Join(",", columns), database, table); _command.Parameters.AddWithValue(null, (long)0); } internal bool IsValid { set { if (value != false) throw new ArgumentException(); if (_reader != null) { _reader.Dispose(); _reader = null; } } } internal void Sync(long rowid) { IsValid = false; _command.Parameters[0].Value = rowid; _reader = _command.ExecuteReader(); _reader.Read(); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(KeyQuery).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// private void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// IsValid = false; if (_command != null) _command.Dispose(); _command = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~KeyQuery() { Dispose(false); } #endregion } /// <summary> /// This function does all the nasty work at determining what keys need to be returned for /// a given statement. /// </summary> /// <param name="cnn"></param> |
︙ | ︙ | |||
255 256 257 258 259 260 261 262 263 264 265 266 267 268 | // Now we have all the additional columns we have to return in order to support // CommandBehavior.KeyInfo _keyInfo = new KeyInfo[keys.Count]; keys.CopyTo(_keyInfo); } /// <summary> /// How many additional columns of keyinfo we're holding /// </summary> internal int Count { get { return (_keyInfo == null) ? 0 : _keyInfo.Length; } } | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 | // Now we have all the additional columns we have to return in order to support // CommandBehavior.KeyInfo _keyInfo = new KeyInfo[keys.Count]; keys.CopyTo(_keyInfo); } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteKeyReader).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// private void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// _stmt = null; if (_keyInfo == null) return; for (int n = 0; n < _keyInfo.Length; n++) { if (_keyInfo[n].query != null) _keyInfo[n].query.Dispose(); } _keyInfo = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteKeyReader() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// How many additional columns of keyinfo we're holding /// </summary> internal int Count { get { return (_keyInfo == null) ? 0 : _keyInfo.Length; } } |
︙ | ︙ | |||
310 311 312 313 314 315 316 | for (int n = 0; n < _keyInfo.Length; n++) { if (_keyInfo[n].query != null) _keyInfo[n].query.IsValid = false; } } | < < < < < < < < < < < < < < | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 | for (int n = 0; n < _keyInfo.Length; n++) { if (_keyInfo[n].query != null) _keyInfo[n].query.IsValid = false; } } internal string GetDataTypeName(int i) { Sync(); if (_keyInfo[i].query != null) return _keyInfo[i].query._reader.GetDataTypeName(_keyInfo[i].column); else return "integer"; } |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteStatement.cs.
︙ | ︙ | |||
84 85 86 87 88 89 90 91 92 93 94 95 96 97 | } _paramNames[x] = s; _paramValues[x] = null; } } } /// <summary> /// Called by SQLiteParameterCollection, this function determines if the specified parameter name belongs to /// this statement, and if so, keeps a reference to the parameter so it can be bound later. /// </summary> /// <param name="s">The parameter name to map</param> /// <param name="p">The parameter to assign it</param> internal bool MapParameter(string s, SQLiteParameter p) | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | } _paramNames[x] = s; _paramValues[x] = null; } } } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable Members /// <summary> /// Disposes and finalizes the statement /// </summary> public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteStatement).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// private void Dispose(bool disposing) { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// if (_sqlite_stmt != null) { _sqlite_stmt.Dispose(); _sqlite_stmt = null; } _paramNames = null; _paramValues = null; _sql = null; _sqlStatement = null; } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// #region Destructor ~SQLiteStatement() { Dispose(false); } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Called by SQLiteParameterCollection, this function determines if the specified parameter name belongs to /// this statement, and if so, keeps a reference to the parameter so it can be bound later. /// </summary> /// <param name="s">The parameter name to map</param> /// <param name="p">The parameter to assign it</param> internal bool MapParameter(string s, SQLiteParameter p) |
︙ | ︙ | |||
113 114 115 116 117 118 119 | _paramValues[n] = p; return true; } } return false; } | < < < < < < < < < < < < < < < < < < < | 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | _paramValues[n] = p; return true; } } return false; } /// <summary> /// Bind all parameters, making sure the caller didn't miss any /// </summary> internal void BindParameters() { if (_paramNames == null) return; |
︙ | ︙ |
Changes to System.Data.SQLite/SQLiteTransaction.cs.
︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | _cnn._transactionLevel--; _cnn = null; throw; } } } /// <summary> /// Commits the current transaction. /// </summary> public override void Commit() { IsValid(true); if (_cnn._transactionLevel - 1 == 0) { using (SQLiteCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "COMMIT"; cmd.ExecuteNonQuery(); } } _cnn._transactionLevel--; _cnn = null; } /// <summary> /// Returns the underlying connection to which this transaction applies. /// </summary> public new SQLiteConnection Connection { | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < < < < < < < < < < < | > | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | _cnn._transactionLevel--; _cnn = null; throw; } } } /////////////////////////////////////////////////////////////////////////////////////////////// #region IDisposable "Pattern" Members private bool disposed; private void CheckDisposed() /* throw */ { #if THROW_ON_DISPOSED if (disposed) throw new ObjectDisposedException(typeof(SQLiteTransaction).Name); #endif } /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Disposes the transaction. If it is currently active, any changes are rolled back. /// </summary> protected override void Dispose(bool disposing) { try { if (!disposed) { if (disposing) { //////////////////////////////////// // dispose managed resources here... //////////////////////////////////// if (IsValid(false)) { IssueRollback(); } } ////////////////////////////////////// // release unmanaged resources here... ////////////////////////////////////// disposed = true; } } finally { base.Dispose(disposing); } } #endregion /////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Commits the current transaction. /// </summary> public override void Commit() { CheckDisposed(); IsValid(true); if (_cnn._transactionLevel - 1 == 0) { using (SQLiteCommand cmd = _cnn.CreateCommand()) { cmd.CommandText = "COMMIT"; cmd.ExecuteNonQuery(); } } _cnn._transactionLevel--; _cnn = null; } /// <summary> /// Returns the underlying connection to which this transaction applies. /// </summary> public new SQLiteConnection Connection { get { CheckDisposed(); return _cnn; } } /// <summary> /// Forwards to the local Connection property /// </summary> protected override DbConnection DbConnection { get { return Connection; } } /// <summary> /// Gets the isolation level of the transaction. SQLite only supports Serializable transactions. /// </summary> public override IsolationLevel IsolationLevel { get { CheckDisposed(); return _level; } } /// <summary> /// Rolls back the active transaction. /// </summary> public override void Rollback() { CheckDisposed(); IsValid(true); IssueRollback(); } internal void IssueRollback() { SQLiteConnection cnn = Interlocked.Exchange(ref _cnn, null); |
︙ | ︙ |
Changes to System.Data.SQLite/SR.Designer.cs.
1 2 3 4 5 6 7 | //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /******************************************************** * 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! ********************************************************/ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated by a tool. // Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. |
︙ | ︙ |
Changes to System.Data.SQLite/System.Data.SQLite.Properties.targets.
︙ | ︙ | |||
46 47 48 49 50 51 52 53 | <!-- NOTE: Emit an AssemblyFlags attribute that includes the Retargetable flag from the AssemblyNameFlags enumeration? --> <PropertyGroup Condition="'$(IsRetargetable)' != 'false'"> <DefineConstants>$(DefineConstants);RETARGETABLE</DefineConstants> </PropertyGroup> </Project> | > > > > > > > | 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <!-- NOTE: Emit an AssemblyFlags attribute that includes the Retargetable flag from the AssemblyNameFlags enumeration? --> <PropertyGroup Condition="'$(IsRetargetable)' != 'false'"> <DefineConstants>$(DefineConstants);RETARGETABLE</DefineConstants> </PropertyGroup> <!-- NOTE: Throw an exception when somebody tries to access a disposed object? --> <PropertyGroup Condition="'$(ThrowOnDisposed)' != 'false'"> <DefineConstants>$(DefineConstants);THROW_ON_DISPOSED</DefineConstants> </PropertyGroup> </Project> |
Changes to testlinq/NorthwindModel2010.Designer.cs.
|
| < < | 1 2 3 4 5 6 7 8 9 10 11 12 13 | /******************************************************** * 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! ********************************************************/ //------------------------------------------------------------------------------ // <auto-generated> // This code was generated from a template. // // Manual changes to this file may cause unexpected behavior in your application. // Manual changes to this file will be overwritten if the code is regenerated. |
︙ | ︙ |
Changes to www/test.wiki.
︙ | ︙ | |||
107 108 109 110 111 112 113 | </li> <li> Make sure all tests pass; the log file "%TEMP%\EagleShell.exe.test.<pid>.log" may be checked if any errors should occur. EagleTest should produce "success" messages very similar to the following:<br /><br /> | | | | 107 108 109 110 111 112 113 114 115 116 117 118 119 | </li> <li> Make sure all tests pass; the log file "%TEMP%\EagleShell.exe.test.<pid>.log" may be checked if any errors should occur. EagleTest should produce "success" messages very similar to the following:<br /><br /> PASSED: 107<br /> TOTAL: 107<br /> PASS PERCENTAGE: 100%<br /> OVERALL RESULT: SUCCESS<br /> </li> </ol> |