rohiroy / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Querying decimal into object results in truncation of data #141

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here is a test that reproduces it:

public void TestDecimalSelect()
{
    using (var connection = Program.GetOpenConnection())
    {
        connection.Execute("select cast(0.090 as decimal(5, 3)) test into tmp_test");
        var query = connection.Query<DecimalObj>("select top 1 test from tmp_test");
        decimal result = query.First().result;
        connection.Execute("drop table tmp_test");
        result.IsEqualTo(0.090m);

    }
}

class DecimalObj
{
    public decimal result { get; set; }
}

If you use connection.Query<decimal> without the object it works, and if if you 
select the decimal without the temporary table it also works.  But querying 
from a real table into an object with a decimal results in 0 being returned 
instead of 0.090.

Original issue reported on code.google.com by shook.di...@gmail.com on 14 Jun 2013 at 3:40

GoogleCodeExporter commented 9 years ago
Not actually a bug, watch for selecting the right field names.

Original comment by shook.di...@gmail.com on 27 Aug 2013 at 9:41