DbExecutionStrategy.UnwrapAndHandleException<T> 方法
[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]
只要是 EntityException、DbUpdateException 或 UpdateException,就會以遞迴方式從 exception 取得 InnerException,並將其傳遞至 exceptionHandler。
命名空間: System.Data.Entity.Infrastructure
組件: EntityFramework (在 EntityFramework.dll 中)
語法
'宣告
Public Shared Function UnwrapAndHandleException(Of T) ( _
exception As Exception, _
exceptionHandler As Func(Of Exception, T) _
) As T
'用途
Dim exception As Exception
Dim exceptionHandler As Func(Of Exception, T)
Dim returnValue As T
returnValue = DbExecutionStrategy.UnwrapAndHandleException(exception, _
exceptionHandler)
public static T UnwrapAndHandleException<T>(
Exception exception,
Func<Exception, T> exceptionHandler
)
public:
generic<typename T>
static T UnwrapAndHandleException(
Exception^ exception,
Func<Exception^, T>^ exceptionHandler
)
static member UnwrapAndHandleException :
exception:Exception *
exceptionHandler:Func<Exception, 'T> -> 'T
JScript does not support generic types and methods.
類型參數
- T
未包裝之例外狀況的類型。
參數
- exception
類型:System.Exception
要解除包裝的例外狀況。
- exceptionHandler
類型:System.Func<Exception, T>
會以未包裝的例外狀況呼叫的委派。
傳回值
類型:T
從 exceptionHandler 產生的結果。