AddOutParameter - non-magic number way of finding length of DBType.Int32

北城余情 提交于 2019-12-22 05:38:13

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/3108881/addoutparameter-non-magic-number-way-of-finding-length-of-dbtype-int32

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!