Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed problem with connection opening

  • Loading branch information...
commit db75bbe61ff6a3719d82abb4dd5d904639a26057 1 parent c8cd622
@markrendle authored
View
4 CommonAssemblyInfo.cs
@@ -19,6 +19,6 @@
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
-[assembly: AssemblyVersion("0.11.2.1")]
-[assembly: AssemblyFileVersion("0.11.2.1")]
+[assembly: AssemblyVersion("0.11.3.1")]
+[assembly: AssemblyFileVersion("0.11.3.1")]
View
10 Simple.Data.Ado/AdoAdapter.cs
@@ -371,7 +371,7 @@ private int Execute(ICommandBuilder commandBuilder)
{
using (var command = commandBuilder.GetCommand(connection))
{
- connection.Open();
+ connection.OpenIfClosed();
return TryExecute(command);
}
}
@@ -449,7 +449,7 @@ public object FindRelated(string tableName, IDictionary<string, object> row, str
public IAdapterTransaction BeginTransaction()
{
var connection = CreateConnection();
- connection.Open();
+ connection.OpenIfClosed();
var transaction = connection.BeginTransaction();
return new AdoAdapterTransaction(transaction);
}
@@ -457,7 +457,7 @@ public IAdapterTransaction BeginTransaction()
public IAdapterTransaction BeginTransaction(IsolationLevel isolationLevel)
{
var connection = CreateConnection();
- connection.Open();
+ connection.OpenIfClosed();
var transaction = connection.BeginTransaction(isolationLevel);
return new AdoAdapterTransaction(transaction);
}
@@ -465,7 +465,7 @@ public IAdapterTransaction BeginTransaction(IsolationLevel isolationLevel)
public IAdapterTransaction BeginTransaction(string name)
{
var connection = CreateConnection();
- connection.Open();
+ connection.OpenIfClosed();
var sqlConnection = connection as SqlConnection;
var transaction = sqlConnection != null ? sqlConnection.BeginTransaction(name) : connection.BeginTransaction();
@@ -475,7 +475,7 @@ public IAdapterTransaction BeginTransaction(string name)
public IAdapterTransaction BeginTransaction(IsolationLevel isolationLevel, string name)
{
var connection = CreateConnection();
- connection.Open();
+ connection.OpenIfClosed();
var sqlConnection = connection as SqlConnection;
var transaction = sqlConnection != null
? sqlConnection.BeginTransaction(isolationLevel, name)
View
3  Simple.Data.Ado/AdoAdapterFinder.cs
@@ -160,8 +160,7 @@ private CommandTemplate GetCommandTemplate(string tableName, SimpleExpression cr
{
try
{
- if (connection.State != ConnectionState.Open)
- connection.Open();
+ connection.OpenIfClosed();
using (var reader = command.ExecuteReader())
{
if (reader.Read())
View
3  Simple.Data.Ado/AdoAdapterGetter.cs
@@ -157,8 +157,7 @@ private CommandTemplate GetCommandTemplate(string tableName, SimpleExpression cr
{
try
{
- if (connection.State != ConnectionState.Open)
- connection.Open();
+ connection.OpenIfClosed();
using (var reader = command.ExecuteReader())
{
if (reader.Read())
View
6 Simple.Data.Ado/AdoAdapterInserter.cs
@@ -108,7 +108,7 @@ private void CheckInsertablePropertiesAreAvailable(Table table, IEnumerable<KeyV
{
using (var command = new CommandHelper(_adapter).CreateInsert(connection, sql, columns, values.ToArray()))
{
- connection.Open();
+ connection.OpenIfClosed();
return TryExecuteSingletonQuery(command);
}
}
@@ -131,7 +131,7 @@ private void CheckInsertablePropertiesAreAvailable(Table table, IEnumerable<KeyV
{
using (var command = new CommandHelper(_adapter).CreateInsert(connection, insertSql, columns, values.ToArray()))
{
- connection.Open();
+ connection.OpenIfClosed();
TryExecute(command);
command.CommandText = selectSql;
command.Parameters.Clear();
@@ -174,7 +174,7 @@ internal int Execute(string sql, IEnumerable<Column> columns, IEnumerable<Object
{
using (var command = new CommandHelper(_adapter).CreateInsert(connection, sql, columns, values.ToArray()))
{
- connection.Open();
+ connection.OpenIfClosed();
return TryExecute(command);
}
}
View
6 Simple.Data.Ado/BulkInserterHelper.cs
@@ -30,7 +30,7 @@ public virtual void InsertRowsWithoutFetchBack(string insertSql)
{
using (var insertCommand = new CommandHelper(Adapter).CreateInsert(connection, insertSql, _columns))
{
- connection.Open();
+ connection.OpenIfClosed();
TryPrepare(insertCommand);
insertCommand.Prepare();
foreach (var row in Data)
@@ -50,7 +50,7 @@ public virtual void InsertRowsWithoutFetchBack(string insertSql)
using (var selectCommand = connection.CreateCommand())
{
selectCommand.CommandText = selectSql;
- connection.Open();
+ connection.OpenIfClosed();
TryPrepare(insertCommand, selectCommand);
return Data.Select(row => InsertRow(row, insertCommand, selectCommand)).ToList();
}
@@ -66,7 +66,7 @@ public virtual void InsertRowsWithoutFetchBack(string insertSql)
{
using (var command = new CommandHelper(Adapter).CreateInsert(connection, insertSql, _columns))
{
- connection.Open();
+ connection.OpenIfClosed();
TryPrepare(command);
return Data.Select(row => InsertRowAndSelect(row, command)).ToList();
}
View
2  Simple.Data.Ado/ConnectionScope.cs
@@ -31,7 +31,7 @@ public static ConnectionScope Create(IDbTransaction transaction, Func<IDbConnect
return new ConnectionScope(transaction.Connection, false);
}
var connection = creator();
- connection.Open();
+ connection.OpenIfClosed();
return new ConnectionScope(connection, true);
}
View
3  Simple.Data.Ado/DataReaderEnumerator.cs
@@ -52,8 +52,7 @@ private void ExecuteReader()
{
try
{
- if (_connection.State == ConnectionState.Closed)
- _connection.Open();
+ _connection.OpenIfClosed();
_reader = _command.ExecuteReader();
if (_reader != null)
{
View
3  Simple.Data.Ado/DataReaderMultipleEnumerator.cs
@@ -53,8 +53,7 @@ private void ExecuteReader()
{
try
{
- if (_connection.State == ConnectionState.Closed)
- _connection.Open();
+ _connection.OpenIfClosed();
_reader = _command.ExecuteReader();
_index = _index ?? _reader.CreateDictionaryIndex();
}
View
20 Simple.Data.Ado/DbConnectionEx.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Simple.Data.Ado
+{
+ using System.Data;
+
+ static class DbConnectionEx
+ {
+ public static void OpenIfClosed(this IDbConnection connection)
+ {
+ if (connection.State == ConnectionState.Closed)
+ {
+ connection.Open();
+ }
+ }
+ }
+}
View
2  Simple.Data.Ado/DelegatingConnectionBase1.cs
@@ -99,7 +99,7 @@ public virtual IDbCommand CreateCommand()
/// <filterpriority>2</filterpriority>
public virtual void Open()
{
- _delegatedConnection.Open();
+ _delegatedConnection.OpenIfClosed();
}
/// <summary>
View
3  Simple.Data.Ado/IObservableQueryRunner.cs
@@ -19,8 +19,7 @@ class ObservableQueryRunner : IObservableQueryRunner
{
try
{
- if (connection.State == ConnectionState.Closed)
- connection.Open();
+ connection.OpenIfClosed();
}
catch (DbException ex)
{
View
4 Simple.Data.Ado/ProcedureExecutor.cs
@@ -71,7 +71,7 @@ private static void RetrieveOutputParameterValues(Procedure procedure, IDbComman
public IEnumerable<ResultSet> ExecuteReader(IDbCommand command)
{
command.WriteTrace();
- command.Connection.Open();
+ command.Connection.OpenIfClosed();
using (var reader = command.ExecuteReader())
{
// Reader isn't always returned - added check to stop NullReferenceException
@@ -90,7 +90,7 @@ private static IEnumerable<ResultSet> ExecuteNonQuery(IDbCommand command)
{
command.WriteTrace();
Trace.TraceInformation("ExecuteNonQuery", "Simple.Data.SqlTest");
- command.Connection.Open();
+ command.Connection.OpenIfClosed();
command.ExecuteNonQuery();
return Enumerable.Empty<ResultSet>();
}
View
1  Simple.Data.Ado/Simple.Data.Ado.csproj
@@ -69,6 +69,7 @@
<Compile Include="DataReaderMultipleEnumerator.cs" />
<Compile Include="DataRecordExtensions.cs" />
<Compile Include="DbCommandExtensions.cs" />
+ <Compile Include="DbConnectionEx.cs" />
<Compile Include="DbConnectionExtensions.cs" />
<Compile Include="DelegatingConnectionBase1.cs" />
<Compile Include="DeleteHelper.cs" />
View
4 Simple.Data.Ado/Simple.Data.Ado.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Ado</id>
- <version>0.11.2.1</version>
+ <version>0.11.3.1</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>ADO Adapter for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Core" version="0.11.2.1" />
+ <dependency id="Simple.Data.Core" version="0.11.3.1" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.Mocking/Simple.Data.Mocking.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.Mocking</id>
- <version>0.11.2.1</version>
+ <version>0.11.3.1</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>XML-based Mocking adapter for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>database data .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="0.11.2.1" />
+ <dependency id="Simple.Data.Ado" version="0.11.3.1" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.SqlCe40/Simple.Data.SqlCe40.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlCompact40</id>
- <version>0.11.2.1</version>
+ <version>0.11.3.1</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server Compact 4.0 ADO provider for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver compact sqlce database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="0.11.2.1" />
+ <dependency id="Simple.Data.Ado" version="0.11.3.1" />
</dependencies>
</metadata>
</package>
View
4 Simple.Data.SqlServer/Simple.Data.SqlServer.nuspec
@@ -2,7 +2,7 @@
<package xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>Simple.Data.SqlServer</id>
- <version>0.11.2.1</version>
+ <version>0.11.3.1</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<description>SQL Server ADO provider for the Simple.Data data access library.</description>
@@ -12,7 +12,7 @@
<tags>sqlserver database data ado .net40</tags>
<language>en-us</language>
<dependencies>
- <dependency id="Simple.Data.Ado" version="0.11.2.1" />
+ <dependency id="Simple.Data.Ado" version="0.11.3.1" />
</dependencies>
</metadata>
</package>
View
2  Simple.Data/Simple.Data.nuspec
@@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>Simple.Data.Core</id>
- <version>0.11.2.1</version>
+ <version>0.11.3.1</version>
<authors>Mark Rendle</authors>
<owners>Mark Rendle</owners>
<licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
Please sign in to comment.
Something went wrong with that request. Please try again.