markrendle / Simple.Data

A light-weight, dynamic data access component for C# 4.0
MIT License
1.33k stars 303 forks source link

simple.data converts null to 0 #328

Open john-qin opened 10 years ago

john-qin commented 10 years ago

I have a Price table in the sql server 2008 r2. one field is called "TotalPrice", its float, and it can be null.

when I select from this table, all null values converted to 0.

if I make it nullable in the domain object. even those are not null, are showing null. not sure I am doing something wrong or this is a bug.

public class Price
{
    public long? TotalPrice{ get; set; }
    Or
    public nullable<long>  TotalPrice{ get; set; }

}

markrendle commented 10 years ago

If you're using Nullable properties in the class, the properties should, indeed, be null. I'll investigate that for you.

One point: if your SQL columns are floats, why are your properties long?

Mark Rendle Founder & CEO Oort Corporation Makers of Zudio https://zud.io/