/// When you specify an Object
/// in the value parameter, the DbType is
/// inferred from the .NET Framework type of the Object.
/// When using this constructor, you must be aware of a possible misuse of the constructor which takes a DbType parameter.
/// This happens when calling this constructor passing an int 0 and the compiler thinks you are passing a value of DbType.
/// Use Convert.ToInt32(value)
for example to have compiler calling the correct constructor.
///
public NpgsqlParameter(String parameterName, object value)
{
resman = new System.Resources.ResourceManager(this.GetType());
NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, CLASSNAME, parameterName, value);
this.ParameterName = parameterName;
this.value = value;
if ((this.value == null) || (this.value == DBNull.Value) )
{
// don't really know what to do - leave default and do further exploration
// Default type for null values is String.
this.value = DBNull.Value;
type_info = NpgsqlTypesHelper.GetNativeTypeInfo(typeof(String));
return;
}
else
{
type_info = NpgsqlTypesHelper.GetNativeTypeInfo(value.GetType());
if (type_info == null)
{
throw new InvalidCastException(String.Format(resman.GetString("Exception_ImpossibleToCast"), value.GetType()));
}
}
}
///