AddOutParameter is not a magic number for finding the length of DBType.Int32

I have a magic number in the following code ...

Microsoft.Practices.EnterpriseLibrary.Data.Database db = /* code omitted */; db.AddOutParameter(command, "@ParamName", DbType.Int32, 8); 

Is there a clean way to get the length of DbType.Int32 as required for the last argument of AddOutParameter ?

+6
c # magic-numbers
source share
1 answer

Not sure what you mean about length. This is a 32-bit int, so it has 4 bytes, which can be 10 digits, as described in this quote from this on the MSDN page. An integral type representing signed 32-bit integers with values โ€‹โ€‹between -2147483648 and 2147483647.

I'm not sure if it makes sense to specify int32 to specify size ( 8 ). For example, if it should match the Oracle Number with the specified size of 8, it probably should be DbType.Decimal , not Int32.

I would suggest studying just deleting 8 as a whole, since this is an output parameter, I donโ€™t think it will affect anything.

+3
source share

All Articles