I rate Dapper as replacing custom and cumbersome code, and so far everything has been very good and promising. But this morning I came across a problem with dynamic parameters and can not find a solution.
The stored procedure calculates the account balance and the available balance so that the client returns its result in two decimal output parameters. These decimals are declared in the stored procedure using Precision = 18 and Scale = 2. This procedure works great with modern standard methods. But in Dapper I canβt find a way to pass these parameters and specify the scale, so all I get is the integer part of the decimal value.
using (IDbConnection connection = OpenConnection()) { var args = new DynamicParameters(new { custID = customerID}); // No way to set the scale here? args.Add("@accnt", dbType: DbType.Decimal, direction: ParameterDirection.Output); args.Add("@avail", dbType: DbType.Decimal, direction: ParameterDirection.Output); var results = connection.QueryMultiple("Customer_CalcBalance", args, commandType:CommandType.StoredProcedure); decimal account = args.Get<decimal>("@accnt"); decimal availab = args.Get<decimal>("@avail"); }
And here is the question (s), is there a way to pass the scale for the decimal output parameter? Or is there another way to accomplish my task to return exact decimal values?
Steve source share