diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-07 10:10:14 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-07 10:10:14 -0800 |
commit | 8abab06d5981a9a9af8dfca4d6e2c13bb2af8665 (patch) | |
tree | ee77cf689a13c59a6559c92a638e929d1c948d39 /projecttemplates/RelyingPartyLogic/Database.cs | |
parent | 79e83026e0842f78b3315e3752443df30fd6181e (diff) | |
parent | 187459a79ff25431a29f64470f7d9e84be87f156 (diff) | |
download | DotNetOpenAuth-8abab06d5981a9a9af8dfca4d6e2c13bb2af8665.zip DotNetOpenAuth-8abab06d5981a9a9af8dfca4d6e2c13bb2af8665.tar.gz DotNetOpenAuth-8abab06d5981a9a9af8dfca4d6e2c13bb2af8665.tar.bz2 |
Merge branch 'master' into nunit
Conflicts:
projecttemplates/RelyingPartyLogic/Utilities.cs
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/Database.cs')
-rw-r--r-- | projecttemplates/RelyingPartyLogic/Database.cs | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/projecttemplates/RelyingPartyLogic/Database.cs b/projecttemplates/RelyingPartyLogic/Database.cs index 9ef72eb..f162b95 100644 --- a/projecttemplates/RelyingPartyLogic/Database.cs +++ b/projecttemplates/RelyingPartyLogic/Database.cs @@ -8,6 +8,7 @@ namespace RelyingPartyLogic { using System; using System.Collections.Generic; using System.Data; + using System.Data.EntityClient; using System.Data.SqlClient; using System.Linq; using System.ServiceModel; @@ -37,21 +38,8 @@ namespace RelyingPartyLogic { DatabaseEntities dataContext = DataContextSimple; if (dataContext == null) { dataContext = new DatabaseEntities(); - try { - dataContext.Connection.Open(); - } catch (EntityException entityEx) { - var sqlEx = entityEx.InnerException as SqlException; - if (sqlEx != null) { - if (sqlEx.Class == 14 && sqlEx.Number == 15350) { - // Most likely the database schema hasn't been created yet. - HttpContext.Current.Response.Redirect("~/Setup.aspx"); - } - } - - throw; - } - - DataContextTransaction = dataContext.Connection.BeginTransaction(); + dataContext.Connection.Open(); + DataContextTransaction = (EntityTransaction)dataContext.Connection.BeginTransaction(); DataContextSimple = dataContext; } @@ -59,14 +47,21 @@ namespace RelyingPartyLogic { } } - internal static IDbTransaction DataContextTransaction { + /// <summary> + /// Gets a value indicating whether the data context is already initialized. + /// </summary> + internal static bool IsDataContextInitialized { + get { return DataContextSimple != null; } + } + + internal static EntityTransaction DataContextTransaction { get { if (HttpContext.Current != null) { - return HttpContext.Current.Items[DataContextTransactionKey] as IDbTransaction; + return HttpContext.Current.Items[DataContextTransactionKey] as EntityTransaction; } else if (OperationContext.Current != null) { object data; if (OperationContext.Current.IncomingMessageProperties.TryGetValue(DataContextTransactionKey, out data)) { - return data as IDbTransaction; + return data as EntityTransaction; } else { return null; } |