开发者

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 o开发者_StackOverflow中文版mitted */;

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜