Final speed optimizations for SQL CE 4...

This commit is contained in:
hartvig
2011-09-14 19:07:09 -02:00
parent 238885746c
commit 62249b989b
3 changed files with 22 additions and 10 deletions

View File

@@ -102,8 +102,6 @@ namespace SqlCE4Umbraco
Debug.WriteLine("----------------------------------------------------------------------------");
Debug.WriteLine(commandText);
Debug.WriteLine("----------------------------------------------------------------------------");
conn.ConnectionString = connectionString;
conn.Open();
SqlCeCommand cmd = new SqlCeCommand(commandText, conn);
AttachParameters(cmd, commandParameters);
rowsAffected = cmd.ExecuteNonQuery();

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Data.SqlServerCe;
using System.Linq;
@@ -9,7 +10,7 @@ namespace SQLCE4Umbraco
{
public static class SqlCeContextGuardian
{
private static SqlCeConnection _conn;
private static SqlCeConnection _constantOpenConnection;
private static object objLock = new object();
// Awesome SQL CE 4 speed improvement by Erik Ejskov Jensen - SQL CE 4 MVP
@@ -27,15 +28,28 @@ namespace SQLCE4Umbraco
}
connectionStringBuilder.Remove("datalayer");
// SQL CE 4 performs better when there's always a connection open in the background
ensureOpenBackgroundConnection(connectionStringBuilder.ConnectionString);
SqlCeConnection conn = new SqlCeConnection(connectionStringBuilder.ConnectionString);
conn.Open();
return conn;
}
private static void ensureOpenBackgroundConnection(string connectionString)
{
lock (objLock)
{
if (_conn != null)
throw new InvalidOperationException("Already opened");
_conn = new SqlCeConnection(connectionStringBuilder.ConnectionString);
_conn.Open();
if (_constantOpenConnection == null)
{
_constantOpenConnection = new SqlCeConnection(connectionString);
_constantOpenConnection.Open();
}
else if (_constantOpenConnection.State != ConnectionState.Open)
_constantOpenConnection.Open();
}
return _conn;
}
}
}

View File

@@ -126,7 +126,7 @@
<p>
<strong>Missing files:</strong> SQL CE 4 requires that you manually add the SQL
CE 4 runtime to your Umbraco installation.<br />
You can either use the following <a href="http://our.umbraco.org/wiki/install-and-setup/using-sql-ce-4-with-juno"
You can either use the following <a href="http://our.umbraco.org/wiki/install-and-setup/using-sql-ce-4-with-umbraco-46"
target="_blank">instructions</a> on how to add SQL CE 4 or select another database type from the dropdown above.
</p>
</div>