This commit is contained in:
@@ -26,7 +26,6 @@
|
|||||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace DynamORM.Tests.Helpers
|
namespace DynamORM.Tests.Helpers
|
||||||
@@ -63,7 +62,7 @@ namespace DynamORM.Tests.Helpers
|
|||||||
Database.Dispose();
|
Database.Dispose();
|
||||||
Database = null;
|
Database = null;
|
||||||
|
|
||||||
Assert.Throws<ObjectDisposedException>(() => cmd.ExecuteScalar());
|
Assert.Throws<DynamicQueryException>(() => cmd.ExecuteScalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Test single mode transaction disposing.</summary>
|
/// <summary>Test single mode transaction disposing.</summary>
|
||||||
|
|||||||
@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.1")]
|
[assembly: AssemblyVersion("1.1.0.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
[assembly: AssemblyFileVersion("1.1.0.1")]
|
||||||
@@ -57,7 +57,7 @@ namespace DynamORM
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_command = _con.Connection.CreateCommand();
|
_command = _con.Connection.CreateCommand();
|
||||||
_db.CommandsPool[_con.Connection].Add(_command);
|
_db.CommandsPool[_con.Connection].Add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,11 +134,13 @@ namespace DynamORM
|
|||||||
////_poolStamp = 0;
|
////_poolStamp = 0;
|
||||||
_command.Connection = _con.Connection;
|
_command.Connection = _con.Connection;
|
||||||
}
|
}
|
||||||
else
|
else if (value == null)
|
||||||
{
|
{
|
||||||
_command.Transaction = null;
|
_command.Transaction = null;
|
||||||
_command.Connection = null;
|
_command.Connection = null;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
throw new InvalidOperationException("Can't assign direct IDbConnection implementation. This property accepts only DynamORM implementation of IDbConnection.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,7 +240,7 @@ namespace DynamORM
|
|||||||
/// <summary>Gets or sets the transaction within which the Command
|
/// <summary>Gets or sets the transaction within which the Command
|
||||||
/// object of a data provider executes.</summary>
|
/// object of a data provider executes.</summary>
|
||||||
/// <remarks>It's does nothing, transaction is peeked from transaction
|
/// <remarks>It's does nothing, transaction is peeked from transaction
|
||||||
/// pool of a connection.</remarks>
|
/// pool of a connection. This is only a dummy.</remarks>
|
||||||
public IDbTransaction Transaction { get { return null; } set { } }
|
public IDbTransaction Transaction { get { return null; } set { } }
|
||||||
|
|
||||||
/// <summary>Gets or sets how command results are applied to the <see cref="T:System.Data.DataRow"/>
|
/// <summary>Gets or sets how command results are applied to the <see cref="T:System.Data.DataRow"/>
|
||||||
@@ -264,13 +266,13 @@ namespace DynamORM
|
|||||||
{
|
{
|
||||||
var pool = _db.CommandsPool.TryGetValue(_con.Connection);
|
var pool = _db.CommandsPool.TryGetValue(_con.Connection);
|
||||||
|
|
||||||
if (pool != null && pool.Contains(_command))
|
if (pool != null && pool.Contains(this))
|
||||||
pool.Remove(_command);
|
pool.Remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_command.Dispose();
|
|
||||||
|
|
||||||
IsDisposed = true;
|
IsDisposed = true;
|
||||||
|
|
||||||
|
_command.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace DynamORM
|
|||||||
internal Dictionary<IDbConnection, Stack<IDbTransaction>> TransactionPool { get; private set; }
|
internal Dictionary<IDbConnection, Stack<IDbTransaction>> TransactionPool { get; private set; }
|
||||||
|
|
||||||
/// <summary>Gets pool of connections and commands.</summary>
|
/// <summary>Gets pool of connections and commands.</summary>
|
||||||
|
/// <remarks>Pool should contain dynamic commands instead of native ones.</remarks>
|
||||||
internal Dictionary<IDbConnection, List<IDbCommand>> CommandsPool { get; private set; }
|
internal Dictionary<IDbConnection, List<IDbCommand>> CommandsPool { get; private set; }
|
||||||
|
|
||||||
/// <summary>Gets schema columns cache.</summary>
|
/// <summary>Gets schema columns cache.</summary>
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ namespace DynamORM
|
|||||||
/// <param name="disposed">This action is invoked when transaction is disposed.</param>
|
/// <param name="disposed">This action is invoked when transaction is disposed.</param>
|
||||||
internal DynamicTransaction(DynamicDatabase db, DynamicConnection con, bool singleTransaction, IsolationLevel? il, Action disposed)
|
internal DynamicTransaction(DynamicDatabase db, DynamicConnection con, bool singleTransaction, IsolationLevel? il, Action disposed)
|
||||||
{
|
{
|
||||||
IsDisposed = false;
|
|
||||||
_db = db;
|
_db = db;
|
||||||
_con = con;
|
_con = con;
|
||||||
_singleTransaction = singleTransaction;
|
_singleTransaction = singleTransaction;
|
||||||
@@ -63,7 +62,8 @@ namespace DynamORM
|
|||||||
_operational = false;
|
_operational = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_db.TransactionPool[_con.Connection].Push(_con.Connection.BeginTransaction());
|
_db.TransactionPool[_con.Connection]
|
||||||
|
.Push(il.HasValue ? _con.Connection.BeginTransaction(il.Value) : _con.Connection.BeginTransaction());
|
||||||
_db.PoolStamp = DateTime.Now.Ticks;
|
_db.PoolStamp = DateTime.Now.Ticks;
|
||||||
_operational = true;
|
_operational = true;
|
||||||
}
|
}
|
||||||
@@ -137,12 +137,10 @@ namespace DynamORM
|
|||||||
|
|
||||||
if (_disposed != null)
|
if (_disposed != null)
|
||||||
_disposed();
|
_disposed();
|
||||||
|
|
||||||
IsDisposed = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
/// <summary>Gets a value indicating whether this instance is disposed.</summary>
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDisposed { get { return !_operational; } }
|
||||||
|
|
||||||
#endregion IExtendedDisposable Members
|
#endregion IExtendedDisposable Members
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,6 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.0.0.1")]
|
[assembly: AssemblyVersion("1.1.0.1")]
|
||||||
[assembly: AssemblyFileVersion("1.0.0.1")]
|
[assembly: AssemblyFileVersion("1.1.0.1")]
|
||||||
[assembly: InternalsVisibleTo("DynamORM.Tests")]
|
[assembly: InternalsVisibleTo("DynamORM.Tests")]
|
||||||
Reference in New Issue
Block a user