diff --git a/DbContextScope.sln b/DbContextScope.sln index f93c8fd..a8f91a3 100644 --- a/DbContextScope.sln +++ b/DbContextScope.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.31101.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo Application", "DemoApplication\Demo Application.csproj", "{977FC0C6-4FDF-4DD9-AAC0-456D4D79C96C}" EndProject diff --git a/Mehdime.Entity/Implementations/DbContextCollection.cs b/Mehdime.Entity/Implementations/DbContextCollection.cs index 578790e..f4410ba 100644 --- a/Mehdime.Entity/Implementations/DbContextCollection.cs +++ b/Mehdime.Entity/Implementations/DbContextCollection.cs @@ -84,6 +84,11 @@ public TDbContext Get() where TDbContext : DbContext return _initializedDbContexts[requestedType] as TDbContext; } + /// + /// When Transaction Committed + /// + public event EventHandler TransactionCommitted; + public int Commit() { if (_disposed) @@ -140,6 +145,8 @@ public int Commit() if (lastError != null) lastError.Throw(); // Re-throw while maintaining the exception's original stack track + OnTransactionCommitted(new EventArgs()); + return c; } @@ -192,6 +199,8 @@ public async Task CommitAsync(CancellationToken cancelToken) if (lastError != null) lastError.Throw(); // Re-throw while maintaining the exception's original stack track + OnTransactionCommitted(new EventArgs()); + return c; } @@ -281,5 +290,12 @@ private static TValue GetValueOrDefault(IDictionary TValue value; return dictionary.TryGetValue(key, out value) ? value : default(TValue); } + + protected void OnTransactionCommitted(EventArgs e) + { + var temp = Volatile.Read(ref TransactionCommitted); + + temp?.Invoke(this, e); + } } } \ No newline at end of file diff --git a/Mehdime.Entity/Interfaces/IDbContextCollection.cs b/Mehdime.Entity/Interfaces/IDbContextCollection.cs index 5476c6c..5463073 100644 --- a/Mehdime.Entity/Interfaces/IDbContextCollection.cs +++ b/Mehdime.Entity/Interfaces/IDbContextCollection.cs @@ -19,5 +19,10 @@ public interface IDbContextCollection : IDisposable /// Get or create a DbContext instance of the specified type. /// TDbContext Get() where TDbContext : DbContext; + + /// + /// When Transaction Committed + /// + event EventHandler TransactionCommitted; } } \ No newline at end of file diff --git a/Mehdime.Entity/Properties/AssemblyInfo.cs b/Mehdime.Entity/Properties/AssemblyInfo.cs index 6a67ff1..0fc1dcd 100644 --- a/Mehdime.Entity/Properties/AssemblyInfo.cs +++ b/Mehdime.Entity/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("1.0.0.2")] +[assembly: AssemblyFileVersion("1.0.0.2")]