From 88b3cba005dfd6121545e3d981c415ab7981d34b Mon Sep 17 00:00:00 2001 From: Christopher Jolly Date: Mon, 1 Jan 2024 01:09:04 +0800 Subject: [PATCH] RetryingExecutionStrategy: Look at the HResult from the actual exception. When trying to create our own pseudo exception for test purposes. We are unable to get an IErrorRecords object, so that we can set the error data and add it to the list of errors. May need to look at a CoCreateInstance method to do it properly or just leave it as is --- src/EFCore.Jet/JetRetryingExecutionStrategy.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/EFCore.Jet/JetRetryingExecutionStrategy.cs b/src/EFCore.Jet/JetRetryingExecutionStrategy.cs index acfd55c..59c6dc7 100644 --- a/src/EFCore.Jet/JetRetryingExecutionStrategy.cs +++ b/src/EFCore.Jet/JetRetryingExecutionStrategy.cs @@ -114,7 +114,7 @@ namespace Microsoft.EntityFrameworkCore protected override bool ShouldRetryOn(Exception exception) { var exceptionFullName = exception.GetType().FullName; - + if (exceptionFullName != "System.Data.OleDb.OleDbException" && exceptionFullName != "System.Data.Odbc.OdbcException") return false; @@ -122,6 +122,10 @@ namespace Microsoft.EntityFrameworkCore if (_additionalErrorNumbers != null) { dynamic sqlException = exception; + if (_additionalErrorNumbers.Contains(exception.HResult)) + { + return true; + } foreach (var err in sqlException.Errors) { if (_additionalErrorNumbers.Contains(err.NativeError))