summaryrefslogtreecommitdiffstats
path: root/projecttemplates/RelyingPartyLogic/NonceDbStore.cs
diff options
context:
space:
mode:
Diffstat (limited to 'projecttemplates/RelyingPartyLogic/NonceDbStore.cs')
-rw-r--r--projecttemplates/RelyingPartyLogic/NonceDbStore.cs17
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();
}