问题
I am working on the mapping from MS SQL database to POCO classes:
I have numeric(19, 0), numeric(18, 0), numeric(3, 0), numeric(3, 0).
I am using the EF power tools to generate POCO and all map to decimal .NET C# Type.
But I think it should map to BigInt, Int64, Int32, Int16 etc.
回答1:
Here are the .NET integer types and their domains with maximum fitting numeric types:
SByte=> -128 to 127 which fits up toNUMERIC(2, 0)Int16=> -32,768 to 32,767 which fits up toNUMERIC(4, 0)Int32=> -2,147,483,648 to 2,147,483,647 which fits up toNUMERIC(9, 0)Int64=> -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 which fits up toNUMERIC(18, 0)
Since a decimal can hold up to 7.9*10^28, it fits up to NUMERIC(28, 0).
If you have an integer field bigger than NUMERIC(28, 0), you can use BigInteger in .NET 4.0 or newer.
回答2:
numeric(x, y) will be decimal. If you want int the correct type is:
SQL / C#
- long / Int64
- int / Int32
- smallint / Int16
来源:https://stackoverflow.com/questions/20712663/how-can-i-map-ms-sql-datatype-numeric19-0-to-net-type