does the sql data type money map to c# float?
相关问题
- Sorting 3 numbers without branching [closed]
- sql execution latency when assign to a variable
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
No.
Money maps to Decimal. If the MONEY column allows null values, it will map to
Nullable<Decimal>.
For details, see SQL-CLR Type Mapping.Float is not nearly precise enough for numerical computations dealing with money. You should always do all of your calculations using decimal values.
No, a
float
has way too low precision to handle monetary values. Seven digits doesn't get you far. Also a floating point type is prone to rounding errors due to how the numbers are represented.Use the
Decimal
data type.No...it maps to a
decimal
. If the column allows null, it maps toNullable<Decimal>
.Mapping CLR Parameter Data
float
isn't precise enough to be used for monetary calculations. You'd be losing/gaining money all over the place.I'd use decimal.