Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AddOutParameter - non-magic number way of finding 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 to AddOutParameter?

like image 290
Richard Ev Avatar asked Jun 24 '10 09:06

Richard Ev


1 Answers

Not sure what you mean about length. It's a 32 bit int so it's 4 bytes which can be 10 digits as described in this quote from this MSDN page. An integral type representing signed 32-bit integers with values between -2147483648 and 2147483647.

I'm not sure hat specifying the size (the 8) for an int32 makes sense. For example, if it should map to an Oracle Number with a specified size of 8 it should probably be DbType.Decimal rather than Int32.

I'd suggest looking into just removing the 8 altogether since it's an output parameter I don't think it would affect anything.

like image 98
Hans Olsson Avatar answered Nov 03 '22 17:11

Hans Olsson