2
我有一個存儲過程交易不匹配只有
CREATE PROCEDURE [dbo].[GetNextImageRequest]
(...) AS
DECLARE @ReturnValue BIT
SET @ReturnValue = 1
-- Set paranoid level isolation: only one access at a time!
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
BEGIN TRANSACTION
BEGIN TRY
...
UPDATE STATEMENT THAT THROWS FOREIGN KEY EXCEPTION
IF @@trancount > 0
BEGIN
COMMIT TRANSACTION
END
SET @ReturnValue = 0
END TRY
BEGIN CATCH
IF @@trancount > 0
BEGIN
ROLLBACK TRANSACTION
END
SET @ReturnValue = 1
END CATCH
SET TRANSACTION ISOLATION LEVEL READ COMMITTED
SET NOCOUNT ON
RETURN @ReturnValue -- 0=success
GO
當我手動調用這個從SQL Server Management Studio中,我沒有得到任何的異常。 當我把這種通過實體框架6,我得到
事務計數後EXECUTE表示 失配數BEGIN和COMMIT語句。以前的計數= 1,當前計數= 0.
我在做什麼錯?外鍵約束正在回滾,但我正在檢查@@ TRANCOUNT。