| | | 1 | | // ReSharper disable once CheckNamespace |
| | | 2 | | namespace Microsoft.EntityFrameworkCore; |
| | | 3 | | |
| | | 4 | | /// <summary> |
| | | 5 | | /// Provider-neutral exception classification. Provider-specific classification (SQL error numbers) lives in the provide |
| | | 6 | | /// e.g. <c>ZhEaIsNsAaBn.Infrastructure.SqlServer</c>, behind <c>IDbErrorClassifier</c>. |
| | | 7 | | /// </summary> |
| | | 8 | | public static class DbExceptionExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary>Classifies a concurrency conflict. Additional data: <c>Entities</c> (the entity type names involved).</ |
| | | 11 | | /// <param name="exception">The exception.</param> |
| | | 12 | | /// <returns>The <c>ConcurrencyException</c> error.</returns> |
| | | 13 | | /// <exception cref="ArgumentNullException"><paramref name="exception"/> is <see langword="null"/>.</exception> |
| | | 14 | | public static Error Classify( this DbUpdateConcurrencyException exception ) |
| | | 15 | | { |
| | 10 | 16 | | ArgumentNullException.ThrowIfNull( exception ); |
| | | 17 | | |
| | 10 | 18 | | var entities = string.Join( ", ", exception.Entries.Select( e => e.Metadata.DisplayName() ).Distinct( StringComp |
| | | 19 | | |
| | | 20 | | |
| | 10 | 21 | | return EfExceptions.ConcurrencyException( exception, new Dictionary<string, object> { [ "Entities" ] = entities |
| | | 22 | | } |
| | | 23 | | } |