System.Data.Common.DbDataReader.Dispose()

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

39 Examples 7

1. Example

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

2. Example

Project: yadal
Source File: EnumerableExtensions.cs
View license
public override void Close() => Dispose();

3. Example

Project: yadal
Source File: Db.cs
View license
public override void Close() => Dispose();

4. Example

Project: linq2db
Source File: DataReaderAsync.cs
View license
public void Dispose()
		{
			if (Reader != null)
				Reader.Dispose();
		}

5. Example

View license
public void Dispose()
            {
                if (!isDisposed)
                {   
                    isDisposed = true;
                    if (!isDataReaderDisposed)
                    {
                        isDataReaderDisposed = true;
                        dataReader.Dispose();
                    }
                    provider.ConnectionManager.ReleaseConnection(this);
                }
            }

6. Example

Project: nhibernate-core
Source File: ResultSetWrapper.cs
View license
protected override void Dispose(bool disposing)
		{
			if (disposed)
				return;

			if (disposing && rs != null)
			{
					rs.Dispose();
				rs = null;
				}

			disposed = true;
		}

7. Example

View license
protected override void Dispose(bool disposing)
		{
			if (disposed)
				return;

			if (disposing && _reader != null)
			{
				_reader.Dispose();
				_reader = null;
			}

			disposed = true;
		}

8. Example

Project: Glimpse
Source File: GlimpseDbDataReader.cs
View license
protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                InnerDataReader.Dispose();
            }

            base.Dispose(disposing);
        }

9. Example

View license
protected override void Dispose(bool disposing)
        {
            _reader?.Dispose();
            _command?.Dispose();
            _reader = null;
            _command = null;
        }

10. Example

Project: TSqlFlex
Source File: FlexResultSet.cs
View license
private static void cleanupReader(SqlDataReader reader)
        {
            if (reader != null)
            {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
                reader.Dispose();
            }
        }

11. Example

View license
public void Dispose()
        {
            _sqlDataReader.Dispose();
            _dbCommand.Dispose();
            _connection.Dispose();
        }

12. Example

Project: logwizard
Source File: database_table_reader.cs
View license
private void dispose_reader() {
            try {
                if ( reader_ != null)
                    reader_.Dispose();
                if ( cmd_ != null)
                    cmd_.Dispose();
            } catch (Exception e) {
                logger.Error("disposing database connection: " + e.Message);
            }

            reader_ = null;
            cmd_ = null;
        }

13. Example

Project: Susanoo
Source File: StreamingScope.cs
View license
public void Dispose()
        {
            if (!_disposed)
            {
                _disposed = true;

                Head.Value = _parent;

#if !DOTNETCORE
                if(_requireThreadAffinity)
                    Thread.EndThreadAffinity();
#endif
                foreach (var weakReference in _instances)
                {
                    DbDataReader disposable;
                    if (weakReference.TryGetTarget(out disposable))
                        disposable.Dispose();
                }
            }
        }

14. Example

View license
private DataTable GetDataTypesCollection(String[] restrictions, OdbcConnection connection){
        /n ..... /n //View Source file for more details /n }

15. Example

Project: sensenet
Source File: SqlProvider.cs
View license
protected internal override List<ContentListType> GetContentListTypesInTree(string path)
        {
            SqlProcedure cmd = null;
            SqlDataReader reader = null;
            var result = new List<ContentListType>();

            cmd = new SqlProcedure
            {
                CommandText = SELECTCONTENTLISTTYPESSCRIPT,
                CommandType = CommandType.Text
            };
            cmd.Parameters.Add("@Path", SqlDbType.NVarChar, 450).Value = path;
            try
            {
                reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    var id = reader.GetInt32(0);
                    var t = NodeTypeManager.Current.ContentListTypes.GetItemById(id);
                    result.Add(t);
                }
            }
            finally
            {
                if (reader != null)
                    reader.Dispose();
                if (cmd != null)
                    cmd.Dispose();
            }
            return result;
        }

16. Example

View license
private DataTable GetColumnsCollection(String[] restrictions, OdbcConnection connection){

            OdbcCommand command = null;
            OdbcDataReader dataReader =null;
            DataTable resultTable = null;
            const int  columnsRestrictionsCount = 4;

            try {
                command = GetCommand(connection);
                String[] allRestrictions = new string[columnsRestrictionsCount];
                FillOutRestrictions(columnsRestrictionsCount,restrictions,allRestrictions,OdbcMetaDataCollectionNames.Columns);

                dataReader = command.ExecuteReaderFromSQLMethod(allRestrictions, ODBC32.SQL_API.SQLCOLUMNS);

                resultTable = DataTableFromDataReader(dataReader, OdbcMetaDataCollectionNames.Columns);
            }

            finally {
                if (dataReader != null) {
                    dataReader.Dispose();
                };
                if (command != null) {
                    command.Dispose();
                };
            }
            return resultTable;
        }

17. Example

View license
private DataTable GetIndexCollection(String[] restrictions, OdbcConnection connection){

           /n ..... /n //View Source file for more details /n }

18. Example

View license
private DataTable GetProcedureColumnsCollection(String[] restrictions, OdbcConnection connection,Boo/n ..... /n //View Source file for more details /n }

19. Example

View license
private DataTable GetTablesCollection(String[] restrictions, OdbcConnection connection, Boolean isTa/n ..... /n //View Source file for more details /n }

20. Example

Project: nhibernate-core
Source File: AbstractBatcher.cs
View license
public void CloseReader(DbDataReader reader)
		{
			/* This method was added because PrepareCommand don't really prepare the command
			 * with its connection. 
			 * In some case we need to manage a reader outsite the command scope. 
			 * To do it we need to use the Batcher.ExecuteReader and then we need something
			 * to close the opened reader.
			 */
			// TODO NH: Study a way to use directly DbCommand.ExecuteReader() outsite the batcher
			// An example of it's use is the management of generated ID.
			if (reader == null)
				return;

			var rsw = reader as ResultSetWrapper;
			var actualReader = rsw == null ? reader : rsw.Target;
			_readersToClose.Remove(actualReader);

			var duration = GetReaderStopwatch(actualReader);

			try
			{
				reader.Dispose();
			}
			catch (Exception e)
			{
				// NH2205 - prevent exceptions when closing the reader from hiding any original exception
				Log.Warn("exception closing reader", e);
			}

			LogCloseReader();
			LogDuration(duration);
		}

21. Example

View license
public bool Execute(TInput criteria)
        {
            SqlDataReader myReader = null;
          /n ..... /n //View Source file for more details /n }

22. Example

Project: ALinq
Source File: AccessDbConnection.cs
View license
protected override void Dispose(bool disposing)
        {
            source.Dispose();
            base.Dispose(disposing);
        }

23. Example

View license
private DataTable GetProceduresCollection(String[] restrictions, OdbcConnection connection){

      /n ..... /n //View Source file for more details /n }

24. Example

Project: Susanoo
Source File: DatabaseManager.cs
View license
[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
        public virtual DbDataReader ExecuteDataReader(string commandText, CommandType commandType, TimeSpan commandTimeout,
            params DbParameter[] parameters)
        {
            if (string.IsNullOrWhiteSpace(commandText))
                throw new ArgumentNullException(nameof(commandText));

            DbDataReader results = null;

            try
            {
                var open = _explicitlyOpened;
                OpenConnectionInternal();

                using (var command = PrepCommand(Connection, commandText, commandType, commandTimeout, parameters))
                {
                    // If the connection was open before execute was called, then do not automatically close connection.
                    results = open ? command.ExecuteReader() : command.ExecuteReader(CommandBehavior.CloseConnection);
                }
            }
            catch
            {
                if (results != null && !results.IsClosed)
                    results.Dispose();

                // ReSharper disable once ExceptionNotDocumented
                // ReSharper disable once ThrowingSystemException
                throw;
            }

            return results;
        }

25. Example

Project: Susanoo
Source File: DatabaseManager.cs
View license
[SuppressMessage("Microsoft.Security", "CA2100:Review SQL queries for security vulnerabilities")]
  /n ..... /n //View Source file for more details /n }

26. Example

Project: sensenet
Source File: SqlProvider.cs
View license
protected internal override NodeHead.NodeVersion[] GetNodeVersions(int nodeId)
        {
           /n ..... /n //View Source file for more details /n }

27. Example

Project: ClearCanvas
Source File: ProcedureQueryBroker.cs
View license
private void InternalFind(TInput criteria, int maxResults, ProcedureQueryCallback<TOutput> cal/n ..... /n //View Source file for more details /n }

28. Example

View license
public override void ReadInternal(byte[] b, int offset, int length)
        {
            if (b.Length == 0)
                return;

            if (_command == null || _reader == null || _reader.IsClosed || offset < _position)
            {
                _reader?.Dispose();
                _command?.Dispose();
                _command = new SqlCommand($"SELECT Content FROM {_options.SchemaName}.[FileContents] WHERE Name = @name", _connection);
                _command.Parameters.AddWithValue("name", _name);
                _reader = _command.ExecuteReader(CommandBehavior.SequentialAccess);
                _reader.Read();
            }
            if (false == _reader.HasRows)
            {
                return;
            }
            if (false == _reader.IsDBNull(0))
            {
                _reader.GetBytes(0, _position, b, offset, length);
            }
            _position += length;
        }

29. Example

Project: sensenet
Source File: SqlProvider.cs
View license
private NodeHead LoadNodeHead(int nodeId, string path, int versionId)
        {
            SqlProce/n ..... /n //View Source file for more details /n }

30. Example

Project: ClearCanvas
Source File: EntityBroker.cs
View license
private void _Find(TSelectCriteria criteria, int? startIndex, int? maxRows, SelectCallback<TServe/n ..... /n //View Source file for more details /n }

31. Example

Project: ClearCanvas
Source File: EnumBroker.cs
View license
List<TOutput> IEnumBroker<TOutput>.Execute() 
        {
            List<TOutput> /n ..... /n //View Source file for more details /n }

32. Example

Project: ClearCanvas
Source File: EntityBroker.cs
View license
public TServerEntity Load(ServerEntityKey entityRef)
        {
            TServerEntity row = null;/n ..... /n //View Source file for more details /n }

33. Example

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

34. Example

View license
public static IEnumerable<T> ExecuteReader<T>( this DatabaseCommand databaseCommand, Fun/n ..... /n //View Source file for more details /n }

35. Example

Project: Aurora-old
Source File: MSSQLDataManager.cs
View license
public override bool TableExists(string table)
        {
            SqlConnection dbcon = GetLockedConnection();
            SqlCommand dbcommand = dbcon.CreateCommand();
            dbcommand.CommandText = string.Format("select table_name from information_schema.tables where table_schema=database() and table_name='{0}'", table.ToLower());
            var rdr = dbcommand.ExecuteReader();

            var ret = false;
            if (rdr.Read())
            {
                ret = true;
            }

            rdr.Close();
            rdr.Dispose();
            dbcommand.Dispose();
            CloseDatabase(dbcon);
            return ret;
        }

36. Example

Project: Fido
Source File: SQL_Queries.cs
View license
public static IEnumerable<string> RunMSsqlQuery(List<string> lSQLInput, string sSrcIP, s/n ..... /n //View Source file for more details /n }

37. Example

Project: Alluvial
Source File: SqlBrokeredDistributor.cs
View license
protected override async Task<Lease<T>> AcquireLease()
        {
            Lease<T&/n ..... /n //View Source file for more details /n }

38. Example

Project: Aurora-old
Source File: MSSQLDataManager.cs
View license
protected override List<ColumnDefinition> ExtractColumnsFromTable(string tableName)
        {
            var defs = new List<ColumnDefinition>();


            SqlConnection dbcon = GetLockedConnection();
            SqlCommand dbcommand = dbcon.CreateCommand();
            dbcommand.CommandText = string.Format("desc {0}", tableName);
            var rdr = dbcommand.ExecuteReader();
            while (rdr.Read())
            {
                var name = rdr["Field"];
                var pk = rdr["Key"];
                var type = rdr["Type"];
                defs.Add(new ColumnDefinition { Name = name.ToString(), IsPrimary = pk.ToString()=="PRI", Type = ConvertTypeToColumnType(type.ToString()) });
            }
            rdr.Close();
            rdr.Dispose();
            dbcommand.Dispose();
            CloseDatabase(dbcon);
            return defs;
        }

39. Example

Project: Fido
Source File: SysMgmt_Landesk.cs
View license
public static FidoReturnValues GetHostOsInfo(FidoReturnValues lFidoReturnValues, string sConnectionS/n ..... /n //View Source file for more details /n }