Browse Source
Merge pull request #16995 from abpframework/concurrency-logger
Log the entries info when `DbUpdateConcurrencyException` occurs.
pull/17107/head
Halil İbrahim Kalkan
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
0 deletions
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
|
|
|
@ -6,6 +6,7 @@ using System.Globalization; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Expressions; |
|
|
|
using System.Reflection; |
|
|
|
using System.Text; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
@ -181,6 +182,20 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext, |
|
|
|
} |
|
|
|
catch (DbUpdateConcurrencyException ex) |
|
|
|
{ |
|
|
|
if (ex.Entries.Count > 0) |
|
|
|
{ |
|
|
|
var sb = new StringBuilder(); |
|
|
|
sb.AppendLine(ex.Entries.Count > 1 |
|
|
|
? "There are some entries which are not saved due to concurrency exception:" |
|
|
|
: "There is an entry which is not saved due to concurrency exception:"); |
|
|
|
foreach (var entry in ex.Entries) |
|
|
|
{ |
|
|
|
sb.AppendLine(entry.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
Logger.LogWarning(sb.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
throw new AbpDbConcurrencyException(ex.Message, ex); |
|
|
|
} |
|
|
|
finally |
|
|
|
|