This commit is contained in:
Rick Falkvinge
2011-12-08 05:03:01 +00:00
parent 0664f3f2cf
commit aa8caeed85
3 changed files with 13 additions and 7 deletions
+7 -6
View File
@@ -6,6 +6,7 @@ using System.Configuration;
using System.IO;
using System.Web;
using Activizr.Basic.Diagnostics;
using MySql.Data;
namespace Activizr.Database
{
@@ -17,7 +18,7 @@ namespace Activizr.Database
public static PirateDb GetDatabase()
{
// First, check if a previous invocation has put anything in the cashe.
string connectionString = CachedConnectionString;
string connectionString = _cachedConnectionString;
// During a cacheless invocation, the app/web config has priority.
if (connectionString == null && ConfigurationManager.ConnectionStrings["Activizr"] != null)
@@ -102,9 +103,9 @@ namespace Activizr.Database
}
// Now write the correct data to the cache, for faster lookup next time.
if (CachedConnectionString == null)
if (_cachedConnectionString == null)
{
CachedConnectionString = connectionString;
_cachedConnectionString = connectionString;
}
PirateDb db = null;
@@ -195,9 +196,9 @@ namespace Activizr.Database
}
// Now write the correct data to the cache, for faster lookup next time
if (CachedConnectionString == null)
if (_cachedConnectionString == null)
{
CachedConnectionString = connectionString;
_cachedConnectionString = connectionString;
}
return new PirateDb(DbProviderFactories.GetFactory(DefaultProviderName), connectionString);
@@ -221,6 +222,6 @@ namespace Activizr.Database
private const string DefaultProviderName = "MySql.Data.SqlClient";
// The cached values used by GetDatabase()
private static string CachedConnectionString = null;
private static string _cachedConnectionString = null;
}
}
+1 -1
View File
@@ -94,7 +94,7 @@
</system.webServer>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
</configuration>
+5
View File
@@ -8,4 +8,9 @@
<compilation debug="true" targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<system.data>
<DbProviderFactories>
<add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.2.2.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
</DbProviderFactories>
</system.data>
</configuration>