Add managed connection pooling and execution locking
This commit is contained in:
101
DynamORM/Helpers/DynamicExecutionReader.cs
Normal file
101
DynamORM/Helpers/DynamicExecutionReader.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* DynamORM - Dynamic Object-Relational Mapping library.
|
||||
* Copyright (c) 2012-2026, Grzegorz Russek (grzegorz.russek@gmail.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
|
||||
namespace DynamORM.Helpers
|
||||
{
|
||||
internal sealed class DynamicExecutionReader : IDataReader
|
||||
{
|
||||
private IDataReader _reader;
|
||||
private IDisposable _scope;
|
||||
|
||||
public DynamicExecutionReader(IDataReader reader, IDisposable scope)
|
||||
{
|
||||
_reader = reader;
|
||||
_scope = scope;
|
||||
}
|
||||
|
||||
public object this[string name] { get { return _reader[name]; } }
|
||||
public object this[int i] { get { return _reader[i]; } }
|
||||
public int Depth { get { return _reader.Depth; } }
|
||||
public bool IsClosed { get { return _reader.IsClosed; } }
|
||||
public int RecordsAffected { get { return _reader.RecordsAffected; } }
|
||||
public int FieldCount { get { return _reader.FieldCount; } }
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (_reader != null)
|
||||
_reader.Close();
|
||||
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
IDataReader reader = _reader;
|
||||
IDisposable scope = _scope;
|
||||
|
||||
_reader = null;
|
||||
_scope = null;
|
||||
|
||||
if (reader != null)
|
||||
reader.Dispose();
|
||||
|
||||
if (scope != null)
|
||||
scope.Dispose();
|
||||
}
|
||||
|
||||
public bool GetBoolean(int i) { return _reader.GetBoolean(i); }
|
||||
public byte GetByte(int i) { return _reader.GetByte(i); }
|
||||
public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { return _reader.GetBytes(i, fieldOffset, buffer, bufferoffset, length); }
|
||||
public char GetChar(int i) { return _reader.GetChar(i); }
|
||||
public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { return _reader.GetChars(i, fieldoffset, buffer, bufferoffset, length); }
|
||||
public IDataReader GetData(int i) { return _reader.GetData(i); }
|
||||
public string GetDataTypeName(int i) { return _reader.GetDataTypeName(i); }
|
||||
public DateTime GetDateTime(int i) { return _reader.GetDateTime(i); }
|
||||
public decimal GetDecimal(int i) { return _reader.GetDecimal(i); }
|
||||
public double GetDouble(int i) { return _reader.GetDouble(i); }
|
||||
public Type GetFieldType(int i) { return _reader.GetFieldType(i); }
|
||||
public float GetFloat(int i) { return _reader.GetFloat(i); }
|
||||
public Guid GetGuid(int i) { return _reader.GetGuid(i); }
|
||||
public short GetInt16(int i) { return _reader.GetInt16(i); }
|
||||
public int GetInt32(int i) { return _reader.GetInt32(i); }
|
||||
public long GetInt64(int i) { return _reader.GetInt64(i); }
|
||||
public string GetName(int i) { return _reader.GetName(i); }
|
||||
public int GetOrdinal(string name) { return _reader.GetOrdinal(name); }
|
||||
public DataTable GetSchemaTable() { return _reader.GetSchemaTable(); }
|
||||
public string GetString(int i) { return _reader.GetString(i); }
|
||||
public object GetValue(int i) { return _reader.GetValue(i); }
|
||||
public int GetValues(object[] values) { return _reader.GetValues(values); }
|
||||
public bool IsDBNull(int i) { return _reader.IsDBNull(i); }
|
||||
public bool NextResult() { return _reader.NextResult(); }
|
||||
public bool Read() { return _reader.Read(); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user