I have a T-SQL stored procedure:
CREATE PROCEDURE [dbo].[GetRequestTest] @RequestId UNIQUEIDENTIFIER AS BEGIN SELECT Request.Amount, Request.Checksum FROM Request WHERE RequestId = @RequestId END
C # mapping class:
public class CustomTest : Itest { public decimal Amount {get;set;} public string Checksum { get; set; } }
I invoke an attempt to call a stored procedure using Dapper:
public void Load(CustomTest obj, Guid RequestId) { using (var con = base.GetClosedConnection()) { con.Open(); var p = new DynamicParameters(); p.Add("@RequestId", dbType: DbType.Guid, direction: ParameterDirection.Input); var result = con.ExecuteReader("[dbo].[GetRequestTest]", param: p, commandType: CommandType.StoredProcedure); while (result.Read()) obj.Amount = (decimal)result["Amount"]; } }
But the result is null
I tried calling to put the SQL statement from the stored procedure directly into C # code - and it works fine, but does not work with the stored procedure.
Any ideas - how to make it work?
c # sql-server stored-procedures dapper
Max Iakovliev
source share