System.Data.Common.DbDataReader.Close()

Here are the examples of the csharp api class System.Data.Common.DbDataReader.Close() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

107 Examples 7

1. Example

Project: RiotControl
Source File: DatabaseReader.cs
View license
public void Close()
		{
			DataReader.Close();
		}

2. Example

Project: ALinq
Source File: DataReader.cs
View license
public override void Close()
        {
            source.Close();
        }

3. Example

Project: ALinq
Source File: Connection.cs
View license
public override void Close()
        {
            source.Close();
        }

4. Example

Project: referencesource
Source File: DbDataReader.cs
View license
protected virtual void Dispose(bool disposing) {
            if (disposing) {
                Close();
            }
        }

5. Example

Project: nhibernate-core
Source File: ResultSetWrapper.cs
View license
public override void Close()
		{
			rs.Close();
		}

6. Example

View license
public override void Close()
		{
			_reader.Close();
		}

7. Example

View license
public override void Close()
        {
            wrappedReader.Close();
        }

8. Example

View license
public override void Close()
        {
            if (_closed)
                throw new InvalidOperationException("already closed");

            _closed = true;

            if (!_resultsReader.IsClosed)
                _resultsReader.Close();
        }

9. Example

Project: EDDiscovery
Source File: SQLiteCommandED.cs
View license
public override void Close()
        {
            InnerReader.Close();

            if (_txnlock != null)
            {
                _txnlock.CloseReader();
                _txnlock = null;
            }
        }

10. Example

Project: encog-dotnet-core
Source File: SQLCODEC.cs
View license
public void Close()
        {
            if (_connection != null)
            {
                _connection.Close();
            }
            if (_results != null)
            {
                _results.Close();
            }
        }

11. Example

Project: ALinq
Source File: AccessDbConnection.cs
View license
public override void Close()
        {
            source.Close();
        }

12. Example

Project: ALinq
Source File: Connection.cs
View license
public override void Close()
        {
            source.Close();
            if (this.closeConnection != null)
                this.closeConnection();
        }

13. Example

Project: referencesource
Source File: BridgeDataReader.cs
View license
override public void Close() {
            // Make sure we explicitly closed the data record, since that's what
            // where using to track closed state.
            DataRecord.CloseExplicitly();

            if (!_isClosed) {
                _isClosed = true;

                if (0 == DataRecord.Depth) {
                    // If we're the root collection, we want to ensure the remainder of
                    // the result column hierarchy is closed out, to avoid dangling
                    // references to it, should it be reused. We also want to physically 
                    // close out the source reader as well.
                    Shaper.Reader.Close();
                }
                else {
                    // For non-root collections, we have to consume all the data, or we'll
                    // not be positioned propertly for what comes afterward.
                    Consume();
                }
            }

            if (NextResultShaperInfoEnumerator != null)
            {
                NextResultShaperInfoEnumerator.Dispose();
                NextResultShaperInfoEnumerator = null;
            }
        }

14. Example

Project: NServiceKit
Source File: ProfiledDbDataReader.cs
View license
public override void Close()
        {
            // this can occur when we're not profiling, but we've inherited from ProfiledDbCommand and are returning a
            // an unwrapped reader from the base command
            if (_reader != null)
            {
                _reader.Close();
            }

            if (_profiler != null)
            {
                _profiler.ReaderFinish(this);
            }
        }

15. Example

View license
public override void Close()
        {
            this.CommitComposer();
            this.wrappedDataReader.Close();
        }

16. Example

Project: Glimpse
Source File: GlimpseDbDataReader.cs
View license
public override void Close()
        {
            if (MessageBroker != null)
            {
                MessageBroker.Publish(
                    new CommandRowCountMessage(ConnectionId, CommandId, RowCount)
                    .AsTimedMessage(TimeSpan.Zero));
            }
              
            InnerDataReader.Close();
        }

17. Example

View license
public IEnumerable<T> ReadCollection(DbDataReader reader, ObjectsChangeTracker changeTracker)
		{
			while (reader.Read())
			{
				T result = MapUsingState(reader, reader);
				if (changeTracker != null)
				{
					changeTracker.RegisterObject(result);
				}
				yield return result;
			}
			reader.Close();
		}

18. Example

Project: SummerBatch
Source File: DataReaderItemReader.cs
View license
protected override void DoClose()
        {
            _initialized = false;
            if (_dataReader!= null)
            {
                _dataReader.Close();
            }
            if (_command != null)
            {
                _command.Dispose();
            }
            if (_connection != null)
            {
                _connection.Close();
            }
        }

19. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public X509CertificateRecord Find (X509Certificate certificate, X509CertificateRecordFields fields)
		{
			if (certificate == null)
				throw new ArgumentNullException (nameof (certificate));

			using (var command = GetSelectCommand (certificate, fields)) {
				var reader = command.ExecuteReader ();

				try {
					if (reader.Read ()) {
						var parser = new X509CertificateParser ();
						var buffer = new byte[4096];

						return LoadCertificateRecord (reader, parser, ref buffer);
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			return null;
		}

20. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IEnumerable<X509Certificate> FindCertificates (IX509Selector selector)
		{
			using (var command = GetSelectCommand (selector, false, false, X509CertificateRecordFields.Certificate)) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CertificateParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						var record = LoadCertificateRecord (reader, parser, ref buffer);
						if (selector == null || selector.Match (record.Certificate))
							yield return record.Certificate;
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			yield break;
		}

21. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IEnumerable<AsymmetricKeyParameter> FindPrivateKeys (IX509Selector selector)
		{
			using (var command = GetSelectCommand (selector, false, true, PrivateKeyFields)) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CertificateParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						var record = LoadCertificateRecord (reader, parser, ref buffer);

						if (selector == null || selector.Match (record.Certificate))
							yield return record.PrivateKey;
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			yield break;
		}

22. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IEnumerable<X509CertificateRecord> Find (MailboxAddress mailbox, DateTime now, bool requirePrivateKey, X509CertificateRecordFields fields)
		{
			if (mailbox == null)
				throw new ArgumentNullException (nameof (mailbox));

			using (var command = GetSelectCommand (mailbox, now, requirePrivateKey, fields)) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CertificateParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						yield return LoadCertificateRecord (reader, parser, ref buffer);
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			yield break;
		}

23. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IEnumerable<X509CertificateRecord> Find (IX509Selector selector, bool trustedOnly, X509CertificateRecordFields fields)
		{
			using (var command = GetSelectCommand (selector, trustedOnly, false, fields | X509CertificateRecordFields.Certificate)) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CertificateParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						var record = LoadCertificateRecord (reader, parser, ref buffer);

						if (selector == null || selector.Match (record.Certificate))
							yield return record;
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			yield break;
		}

24. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IEnumerable<X509CrlRecord> Find (X509Name issuer, X509CrlRecordFields fields)
		{
			if (issuer == null)
				throw new ArgumentNullException (nameof (issuer));

			using (var command = GetSelectCommand (issuer, fields)) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CrlParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						yield return LoadCrlRecord (reader, parser, ref buffer);
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			yield break;
		}

25. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public X509CrlRecord Find (X509Crl crl, X509CrlRecordFields fields)
		{
			if (crl == null)
				throw new ArgumentNullException (nameof (crl));

			using (var command = GetSelectCommand (crl, fields)) {
				var reader = command.ExecuteReader ();

				try {
					if (reader.Read ()) {
						var parser = new X509CrlParser ();
						var buffer = new byte[4096];

						return LoadCrlRecord (reader, parser, ref buffer);
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			return null;
		}

26. Example

Project: Aurora-old
Source File: Migration.cs
View license
protected virtual int FindVersion(DbConnection conn, string type)
        {
            int version = 0;
            using (DbCommand cmd = conn.CreateCommand())
            {
                try
                {
                    cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc";
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            version = Convert.ToInt32(reader["version"]);
                        }
                        reader.Close();
                    }
                }
                catch
                {
                    // Something went wrong (probably no table), so we're at version -1
                    version = -1;
                }
            }
            return version;
        }

27. Example

Project: VoxelSim
Source File: Migration.cs
View license
protected virtual int FindVersion(DbConnection conn, string type)
        {
            int version = 0;
            using (DbCommand cmd = conn.CreateCommand())
            {
                try
                {
                    cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc";
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            version = Convert.ToInt32(reader["version"]);
                        }
                        reader.Close();
                    }
                }
                catch
                {
                    // Something went wrong (probably no table), so we're at version -1
                    version = -1;
                }
            }
            return version;
        }

28. Example

Project: opensimulator
Source File: Migration.cs
View license
protected virtual int FindVersion(DbConnection conn, string type)
        {
            int version = 0;
            using (DbCommand cmd = conn.CreateCommand())
            {
                try
                {
                    cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc";
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        if (reader.Read())
                        {
                            version = Convert.ToInt32(reader["version"]);
                        }
                        reader.Close();
                    }
                }
                catch
                {
                    // Something went wrong (probably no table), so we're at version -1
                    version = -1;
                }
            }
            return version;
        }

29. Example

Project: nhibernate-core
Source File: NDataReader.cs
View license
public static NDataReader Create(DbDataReader reader, bool isMidstream)
		{
			var dataReader = new NDataReader();
			var resultList = new List<NResult>(2);

			try
			{
				// if we are in midstream of processing a DataReader then we are already
				// positioned on the first row (index=0)
				if (isMidstream)
				{
					dataReader.currentRowIndex = 0;
				}

				// there will be atleast one result 
				resultList.Add(NResult.Create(reader, isMidstream));

				while (reader.NextResult())
				{
					// the second, third, nth result is not processed midstream
					resultList.Add(NResult.Create(reader, false));
				}

				dataReader.results = resultList.ToArray();
			}
			catch (Exception e)
			{
				throw new ADOException("There was a problem converting an DbDataReader to NDataReader", e);
			}
			finally
			{
				reader.Close();
			}
			return dataReader;
		}

30. Example

Project: nuodb-dotnet
Source File: TestFixture.cs
View license
[Test]
        public void TestCommand1()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DbCommand command = new NuoDbCommand("select * from hockey", connection);

                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", reader[0], reader[1], reader[2], reader["id"]);
                }
                reader.Close();
            }
        }

31. Example

View license
public async Task<dynamic> Documento(int id)
		{
			using (Banco banco = new Banco())
			{
			/n ..... /n //View Source file for more details /n }

32. Example

View license
public async Task<dynamic> DocumentosDoMesmoDia(int id)
		{
			using (Banco banco = new Banco(/n ..... /n //View Source file for more details /n }

33. Example

View license
public async Task<dynamic> DocumentosDaSubcotaMes(int id)
		{
			using (Banco banco = new Banc/n ..... /n //View Source file for more details /n }

34. Example

View license
public DataTable ReadData(DatasetConfig datasetConfig, string filter, long Start, int Count, DateTime? Fromdate, DateTime? ToDate)
        {
            try
            {
                CheckAndEstablishReadConnection();

                readCmd.Connection = readDBConn;
                readCmd.CommandText = "SELECT * FROM " + datasetConfig.Name + " LIMIT " + Count.ToString() + " OFFSET " + Start.ToString();
                DbDataReader akReader = readCmd.ExecuteReader();

                DataTable myTbl = new DataTable();
                myTbl.Load(akReader);
                akReader.Close();

                return myTbl;
            }
            catch (Exception ex)
            { }
            return null;
        }

35. Example

View license
public DataTable ReadData(DatasetConfig datasetConfig, string filter, long Start, int Count, DateTime? Fromdate, DateTime? ToDate)
        {
            try
            {
                CheckAndEstablishReadConnection();

                readCmd.Connection = readDBConn;
                readCmd.CommandText = "SELECT * FROM " + datasetConfig.Name + " LIMIT " + Count.ToString() + " OFFSET " + Start.ToString();
                DbDataReader akReader = readCmd.ExecuteReader();

                DataTable myTbl = new DataTable();
                myTbl.Load(akReader);
                akReader.Close();

                return myTbl;
            }
            catch (Exception ex)
            { }
            return null;
        }

36. Example

Project: MimeKit
Source File: X509CertificateDatabase.cs
View license
public IX509Store GetCrlStore ()
		{
			var crls = new List<X509Crl> ();

			using (var command = GetSelectAllCrlsCommand ()) {
				var reader = command.ExecuteReader ();

				try {
					var parser = new X509CrlParser ();
					var buffer = new byte[4096];

					while (reader.Read ()) {
						var record = LoadCrlRecord (reader, parser, ref buffer);
						crls.Add (record.Crl);
					}
				} finally {
#if NETSTANDARD
					reader.Dispose ();
#else
					reader.Close ();
#endif
				}
			}

			return X509StoreFactory.Create ("Crl/Collection", new X509CollectionStoreParameters (crls));
		}

37. Example

Project: nuodb-dotnet
Source File: TestFixture.cs
View license
[Test]
        public void TestHighAvailability()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString.Replace("Server=", "Server=localhost:8,")))
            {
                DbCommand command = new NuoDbCommand("select * from hockey", connection);

                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    Console.WriteLine("\t{0}\t{1}\t{2}\t{3}", reader[0], reader[1], reader[2], reader["id"]);
                }
                reader.Close();
            }
        }

38. Example

View license
public DataTable ReadData(DatasetConfig datasetConfig, string filter, long Start, int Count, DateTim/n ..... /n //View Source file for more details /n }

39. Example

View license
public DataTable ReadData(DatasetConfig datasetConfig, string sql, int Count)
        {
            //try
            {
                CheckAndEstablishReadConnection();

                readCmd.Connection = readDBConn;
                readCmd.CommandText = sql.Trim();
                if (readCmd.CommandText.EndsWith(";"))
                    readCmd.CommandText = readCmd.CommandText.Substring(0, readCmd.CommandText.Length - 1);
                //if (!readCmd.CommandText.Contains("ORDER BY"))
                //    readCmd.CommandText += " ORDER BY id DESC";
                //if (!readCmd.CommandText.Contains("LIMIT") && !readCmd.CommandText.Contains("OFFSET"))
                //    readCmd.CommandText += " LIMIT " + Count.ToString();
                DbDataReader akReader = readCmd.ExecuteReader();

                DataTable myTbl = new DataTable();
                myTbl.Load(akReader);
                akReader.Close();

                return myTbl;
            }
            //catch (Exception ex)
            { }
            return null;
        }

40. Example

View license
public DataTable ReadData(DatasetConfig datasetConfig, string filter, long Start, int Count, DateTim/n ..... /n //View Source file for more details /n }

41. Example

Project: Lidarr
Source File: DataMapper.cs
View license
public void ExecuteReader(string sql, Action<DbDataReader> action)
        {
            if (string.IsNullOrEmpty(sql))
                throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");

            Command.CommandText = sql;

            try
            {
                OpenConnection();

                DbDataReader reader = null;
                try
                {
                    reader = Command.ExecuteReader();

                    while (reader.Read())
                    {
                        action(reader);
                    }
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
            }
            finally
            {
                CloseConnection();
            }
        }

42. Example

Project: nhibernate-core
Source File: NDataReader.cs
View license
public static async Task<NDataReader> CreateAsync(DbDataReader reader, bool isMidstream, CancellationToken cancellationToken)
		{
			cancellationToken.ThrowIfCancellationRequested();
			var dataReader = new NDataReader();
			var resultList = new List<NResult>(2);

			try
			{
				// if we are in midstream of processing a DataReader then we are already
				// positioned on the first row (index=0)
				if (isMidstream)
				{
					dataReader.currentRowIndex = 0;
				}

				// there will be atleast one result 
				resultList.Add(await (NResult.CreateAsync(reader, isMidstream, cancellationToken)).ConfigureAwait(false));

				while (await (reader.NextResultAsync(cancellationToken)).ConfigureAwait(false))
				{
					// the second, third, nth result is not processed midstream
					resultList.Add(await (NResult.CreateAsync(reader, false, cancellationToken)).ConfigureAwait(false));
				}

				dataReader.results = resultList.ToArray();
			}
			catch (Exception e)
			{
				throw new ADOException("There was a problem converting an DbDataReader to NDataReader", e);
			}
			finally
			{
				reader.Close();
			}
			return dataReader;
		}

43. Example

View license
public virtual async Task<long> GetNextValueAsync(CancellationToken cancellationToken)
			{
				cancellationToken.ThrowIfCancellationRequested();
				_owner._accessCounter++;
				try
				{
					var st = await (_session.Batcher.PrepareCommandAsync(CommandType.Text, _owner._sql, SqlTypeFactory.NoTypes, cancellationToken)).ConfigureAwait(false);
					DbDataReader rs = null;
					try
					{
						rs = await (_session.Batcher.ExecuteReaderAsync(st, cancellationToken)).ConfigureAwait(false);
						try
						{
							await (rs.ReadAsync(cancellationToken)).ConfigureAwait(false);
							long result = Convert.ToInt64(rs.GetValue(0));
							if (Log.IsDebugEnabled)
							{
								Log.Debug("Sequence value obtained: " + result);
							}
							return result;
						}
						finally
						{
							try
							{
								rs.Close();
							}
							catch
							{
								// intentionally empty
							}
						}
					}
					finally
					{
						_session.Batcher.CloseCommand(st, rs);
					}
				}
				catch (DbException sqle)
				{
					throw ADOExceptionHelper.Convert(_session.Factory.SQLExceptionConverter, sqle, "could not get next sequence value", _owner._sql);
				}
			}

44. Example

Project: nuodb-dotnet
Source File: TestFixture.cs
View license
[Test]
        public void TestParameter()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DbCommand command = connection.CreateCommand();
                connection.Open();

                command.CommandText = "select * from hockey where number = ?";
                command.Prepare();
                command.Parameters[0].Value = "2";

                DbDataReader reader = command.ExecuteReader();
                Assert.IsFalse(reader.Read());
                reader.Close();
            }
        }

45. Example

Project: nuodb-dotnet
Source File: TestFixture.cs
View license
[Test]
        public void TestPrepareNoParameter()
        {
            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DbCommand command = connection.CreateCommand();
                connection.Open();

                command.CommandText = "select * from hockey where number = 2";
                command.Prepare();

                DbDataReader reader = command.ExecuteReader();
                Assert.IsFalse(reader.Read());
                reader.Close();
            }
        }

46. Example

Project: nuodb-dotnet
Source File: TestFixture.cs
View license
[Test]
        public void TestBulkLoad_DataReaderNoMapping()
        {
            CreateTargetForBulkLoad();

            NuoDbBulkLoader loader = new NuoDbBulkLoader(connectionString);
            loader.BatchSize = 2;
            loader.DestinationTableName = "TEMP";

            using (NuoDbConnection connection = new NuoDbConnection(connectionString))
            {
                DbCommand command = new NuoDbCommand("select position from hockey order by number", connection);

                connection.Open();
                DbDataReader reader = command.ExecuteReader();
                loader.WriteToServer(reader);
                reader.Close();

                command = new NuoDbCommand("select count(*) from hockey", connection);
                object val = command.ExecuteScalar();
                VerifyBulkLoad(Utils.ToInt(val), "Fan");
            }
        }

47. Example

Project: Radarr
Source File: DataMapper.cs
View license
public void ExecuteReader(string sql, Action<DbDataReader> action)
        {
            if (string.IsNullOrEmpty(sql))
                throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");

            Command.CommandText = sql;

            try
            {
                OpenConnection();

                DbDataReader reader = null;
                try
                {
                    reader = Command.ExecuteReader();

                    while (reader.Read())
                    {
                        action(reader);
                    }
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
            }
            finally
            {
                CloseConnection();
            }
        }

48. Example

Project: Rhetos
Source File: MsSqlExecuter.cs
View license
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
        public void ExecuteReader(string commandText, Action<DbDataReader> action)
        {
            _logger.Trace(() => "Executing reader: " + commandText);

            SafeExecuteCommand(
                sqlCommand =>
                {
                    var sw = Stopwatch.StartNew();
                    try
                    {
                        sqlCommand.CommandText = commandText;
                        var dataReader = sqlCommand.ExecuteReader();
                        while (!dataReader.IsClosed && dataReader.Read())
                            action(dataReader);
                        dataReader.Close();
                    }
                    finally
                    {
                        LogPerformanceIssue(sw, commandText);
                    }
                },
                _persistenceTransaction != null);
        }

49. Example

Project: Sonarr
Source File: DataMapper.cs
View license
public void ExecuteReader(string sql, Action<DbDataReader> action)
        {
            if (string.IsNullOrEmpty(sql))
                throw new ArgumentNullException("sql", "A SQL query or stored procedure name is required");

            Command.CommandText = sql;

            try
            {
                OpenConnection();

                DbDataReader reader = null;
                try
                {
                    reader = Command.ExecuteReader();

                    while (reader.Read())
                    {
                        action(reader);
                    }
                }
                finally
                {
                    if (reader != null) reader.Close();
                }
            }
            finally
            {
                CloseConnection();
            }
        }

50. Example

View license
public override void CreateOrModify_TablesAndFields(string dataTable, DatasetConfig datasetConfig)
 /n ..... /n //View Source file for more details /n }