我正在使用以下代码更新记录,它更新了特定记录,但返回-1。
我正在使用Dapper执行此过程:
ALTER PROCEDURE [dbo].[Contact]
@ContactId VARCHAR(50) ,
@AccountId VARCHAR(50) ,
@EmailAddress NVARCHAR(100)
AS
BEGIN
DECLARE MID bigint = 0
SELECT TOP 1 MID = CID
FROM Type3002
WHERE ATTRIBUTE_2710 LIKE CAST(@EMailAddress AS VARCHAR(100))
IF NOT EXISTS (SELECT * FROM Type3002
WHERE ContactId LIKE '%,' + CAST(@ContactId AS VARCHAR(100)) + ',%')
BEGIN
UPDATE Type3002
SET ATTRIBUTE_2710 = LEFT(@EMailAddress, 50),
ContactId = ContactId +',' + @ContactId,
AccountId = AccountId ++','+ @AccountId
WHERE CID = MID
END
ELSE IF NOT EXISTS (SELECT * FROM Type3002
WHERE AccountId LIKE '%,' + @AccountId + ',%'
AND ContactId LIKE '%,' + @ContactId)
BEGIN
UPDATE Type3002
SET AccountId = AccountId +','+ @AccountId
WHERE CID = MID
END
END
调用此过程的代码如下:
var result = await connection.ExecuteAsync("[Contact]",
答案 0 :(得分:2)