Replies: 1 comment
-
@sonkt Hi, it is not related to this library, check Dapper Docs, please. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi @phnx47 !
I have a problem with ExecuteAsync Method.
C# Code:
var dynParams = new DynamicParameters(); dynParams.Add("@newCode", dbType: DbType.Int32, direction:ParameterDirection.Output); dynParams.Add("@prefix", value: prefix, dbType: DbType.String, direction:ParameterDirection.Input); var commandDefinition = new CommandDefinition("[dbo].[GetNextReceiptCode]", dynParams, dbTransaction, null, CommandType.StoredProcedure); var _connection = _repository.GetConnection(); var result = await _connection.ExecuteAsync(commandDefinition);
Generated Sql:
declare @p2 int set @p2=1 exec [dbo].[GetNextReceiptCode] @prefix='PT-HQT/2023',@newCode=@p2 output select @p2
SQL Store Procedure:
Create PROCEDURE [dbo].[GetNextReceiptCode] @prefix varchar(max), @newCode int output AS BEGIN SELECT @newCode= ISNULL(MAX(RIGHT(ReceiptCode,CHARINDEX('/',REVERSE(ReceiptCode) +'/')-1)),0) + 1 FROM [Receipts] where ReceiptCode like @prefix+'%' END
When I execute Generated SQL, it returns 1 (it's right).
But when I call via C#, '_connection.ExecuteAsync(commandDefinition)' returns -1, although generated SQL is correct.
Please help me!
Beta Was this translation helpful? Give feedback.
All reactions