AddOutParameter - DBType.Int32的发现长度的非幻数的方法 [英] 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);
有没有干净的方式来获得 DbType.Int32 长度code>,因为所需的最后一个参数
AddOutParameter
?
Is there a clean way to get the length of DbType.Int32
, as required for the last argument to AddOutParameter
?
推荐答案
不知道你的意思是什么长度。这是一个32位的int所以它的4个字节可以是从的这个 MSDN页面。的整型表示与-2147483648和2147483647之间的值符号的32位整数。的
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.
我不知道帽子的指定大小( 8
)的一个Int32是有道理的。例如,如果它应该映射到Oracle 编号
为8的指定大小大概应 DbType.Decimal
而不是的Int32。
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.
我会建议寻找到刚刚取出8完全因为它是一个输出参数,我不认为这会影响什么。
I'd suggest looking into just removing the 8 altogether since it's an output parameter I don't think it would affect anything.
这篇关于AddOutParameter - DBType.Int32的发现长度的非幻数的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!