Dapper query - dealing with decimal and double

c# dapper

Question

I'm having issues getting the decimal points from double and decimal SQL server column fields using Dapper 1.2.1 and tried 1.4 as well.

Using the code below, I'm getting "1" instead of "1.44".

Thanks in advance!

Table Creation

CREATE TABLE [dbo].[Test](
    [Id] [bigint] IDENTITY(1,1) NOT NULL,
    [Value] [decimal](10,2) NOT NULL
CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED 
(
    [Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY])

Data in table

INSERT INTO Test ([Value]) VALUES (1.44)

Class

class Test
{
    public long Id {get;set;}
    public decimal {get;set;}
}

DAO

var result = dbConn.Query<Test>("SELECT * FROM TEST");

Popular Answer

Confirmed it's a test data problem. Dapper is working as expected in this regard.




Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why