Using decimal with specific precision as output parameters with Dapper

前端 未结 3 857
轮回少年
轮回少年 2021-01-13 08:27

I am evaluating Dapper as a replacement for custom and cumbersome code and so far all was very good and promising. But this morning I have stumbled on a problem with Dynamic

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-13 09:14

    A little late to the party, but I thought I would mention that this was fixed in 2015. Here is the GitHub issue. Example usage:

    public void Issue261_Decimals()
    {
        var parameters = new DynamicParameters();
        parameters.Add("c", dbType: DbType.Decimal, direction: ParameterDirection.Output, precision: 10, scale: 5);
        connection.Execute("create proc #Issue261 @c decimal(10,5) OUTPUT as begin set @c=11.884 end");
        connection.Execute("#Issue261", parameters, commandType: CommandType.StoredProcedure);
        var c = parameters.Get("c");
        c.IsEqualTo(11.884M);
    }
    

提交回复
热议问题