This commit is contained in:
grzegorz.russek
2013-06-06 08:03:45 +00:00
parent 69f94ae5b0
commit b12a838a4f
6 changed files with 18 additions and 18 deletions

View File

@@ -26,7 +26,6 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using NUnit.Framework;
namespace DynamORM.Tests.Helpers
@@ -63,7 +62,7 @@ namespace DynamORM.Tests.Helpers
Database.Dispose();
Database = null;
Assert.Throws<ObjectDisposedException>(() => cmd.ExecuteScalar());
Assert.Throws<DynamicQueryException>(() => cmd.ExecuteScalar());
}
/// <summary>Test single mode transaction disposing.</summary>

View File

@@ -61,5 +61,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]

View File

@@ -57,7 +57,7 @@ namespace DynamORM
else
{
_command = _con.Connection.CreateCommand();
_db.CommandsPool[_con.Connection].Add(_command);
_db.CommandsPool[_con.Connection].Add(this);
}
}
}
@@ -134,11 +134,13 @@ namespace DynamORM
////_poolStamp = 0;
_command.Connection = _con.Connection;
}
else
else if (value == null)
{
_command.Transaction = 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
/// object of a data provider executes.</summary>
/// <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 { } }
/// <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);
if (pool != null && pool.Contains(_command))
pool.Remove(_command);
if (pool != null && pool.Contains(this))
pool.Remove(this);
}
_command.Dispose();
IsDisposed = true;
_command.Dispose();
}
}

View File

@@ -87,6 +87,7 @@ namespace DynamORM
internal Dictionary<IDbConnection, Stack<IDbTransaction>> TransactionPool { get; private set; }
/// <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; }
/// <summary>Gets schema columns cache.</summary>

View File

@@ -49,7 +49,6 @@ namespace DynamORM
/// <param name="disposed">This action is invoked when transaction is disposed.</param>
internal DynamicTransaction(DynamicDatabase db, DynamicConnection con, bool singleTransaction, IsolationLevel? il, Action disposed)
{
IsDisposed = false;
_db = db;
_con = con;
_singleTransaction = singleTransaction;
@@ -63,7 +62,8 @@ namespace DynamORM
_operational = false;
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;
_operational = true;
}
@@ -137,12 +137,10 @@ namespace DynamORM
if (_disposed != null)
_disposed();
IsDisposed = true;
}
/// <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
}

View File

@@ -62,6 +62,6 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
[assembly: AssemblyVersion("1.1.0.1")]
[assembly: AssemblyFileVersion("1.1.0.1")]
[assembly: InternalsVisibleTo("DynamORM.Tests")]