diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-01 19:04:55 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-01 19:04:55 -0800 |
commit | 6805d02a0e5d480b8546698e01feaadef3a936c5 (patch) | |
tree | bc08848a0df8a51872136d287c982bbf5159dbf6 /projecttemplates/RelyingPartyLogic/NonceDbStore.cs | |
parent | 70446775807fde815cc1885f6f0fa75a79b861ac (diff) | |
download | DotNetOpenAuth-6805d02a0e5d480b8546698e01feaadef3a936c5.zip DotNetOpenAuth-6805d02a0e5d480b8546698e01feaadef3a936c5.tar.gz DotNetOpenAuth-6805d02a0e5d480b8546698e01feaadef3a936c5.tar.bz2 |
Fixed intermittent error while executing SQL stored procedures.
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/NonceDbStore.cs')
-rw-r--r-- | projecttemplates/RelyingPartyLogic/NonceDbStore.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/projecttemplates/RelyingPartyLogic/NonceDbStore.cs b/projecttemplates/RelyingPartyLogic/NonceDbStore.cs index 2f3c670..951bf0f 100644 --- a/projecttemplates/RelyingPartyLogic/NonceDbStore.cs +++ b/projecttemplates/RelyingPartyLogic/NonceDbStore.cs @@ -9,6 +9,7 @@ namespace RelyingPartyLogic { using System.Collections.Generic; using System.Data; using System.Data.Common; + using System.Data.EntityClient; using System.Linq; using System.Text; using DotNetOpenAuth.Configuration; @@ -90,7 +91,7 @@ namespace RelyingPartyLogic { private static void ClearNoncesIfAppropriate() { if (++nonceClearingCounter % NonceClearingInterval == 0) { using (var dataContext = new TransactedDatabaseEntities(IsolationLevel.ReadCommitted)) { - dataContext.ClearExpiredNonces(); + dataContext.ClearExpiredNonces(dataContext.Transaction); } } } @@ -100,27 +101,27 @@ namespace RelyingPartyLogic { /// </summary> protected class TransactedDatabaseEntities : DatabaseEntities { /// <summary> - /// The transaction for this data context. - /// </summary> - private DbTransaction transaction; - - /// <summary> /// Initializes a new instance of the <see cref="TransactedDatabaseEntities"/> class. /// </summary> /// <param name="isolationLevel">The isolation level.</param> public TransactedDatabaseEntities(IsolationLevel isolationLevel) { this.Connection.Open(); - this.transaction = this.Connection.BeginTransaction(isolationLevel); + this.Transaction = (EntityTransaction)this.Connection.BeginTransaction(isolationLevel); } /// <summary> + /// Gets the transaction for this data context. + /// </summary> + public EntityTransaction Transaction { get; private set; } + + /// <summary> /// Releases the resources used by the object context. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected override void Dispose(bool disposing) { try { this.SaveChanges(); - this.transaction.Commit(); + this.Transaction.Commit(); } finally { this.Connection.Close(); } |