本文整理匯總了C#中Npgsql.NpgsqlParameter.ResetSqlDbType方法的典型用法代碼示例。如果您正苦於以下問題:C# NpgsqlParameter.ResetSqlDbType方法的具體用法?C# NpgsqlParameter.ResetSqlDbType怎麽用?C# NpgsqlParameter.ResetSqlDbType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Npgsql.NpgsqlParameter
的用法示例。
在下文中一共展示了NpgsqlParameter.ResetSqlDbType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ResetSqlDbType
public void ResetSqlDbType ()
{
//Parameter with an assigned value but no NpgsqlDbType specified
NpgsqlParameter p1 = new NpgsqlParameter ("foo", 42);
Assert.AreEqual (42, p1.Value, "#1");
Assert.AreEqual (DbType.Int32, p1.DbType, "#2");
Assert.AreEqual (NpgsqlDbType.Integer, p1.NpgsqlDbType, "#3");
p1.ResetSqlDbType ();
Assert.AreEqual (DbType.Int32, p1.DbType, "#4 The parameter with value 42 must have DbType as Int32");
Assert.AreEqual (NpgsqlDbType.Integer, p1.NpgsqlDbType, "#5 The parameter with value 42 must have NpgsqlDbType as Int");
p1.NpgsqlDbType = NpgsqlDbType.Timestamp; //assigning a NpgsqlDbType
Assert.AreEqual (DbType.DateTime, p1.DbType, "#6");
Assert.AreEqual (NpgsqlDbType.Timestamp, p1.NpgsqlDbType, "#7");
p1.ResetSqlDbType (); //Resetting NpgsqlDbType
Assert.AreEqual (DbType.Int32, p1.DbType, "#8 Resetting NpgsqlDbType must infer the type from the value");
Assert.AreEqual (NpgsqlDbType.Integer, p1.NpgsqlDbType, "#9 Resetting NpgsqlDbType must infer the type from the value");
//Parameter with an assigned NpgsqlDbType but no specified value
NpgsqlParameter p2 = new NpgsqlParameter ("foo", NpgsqlDbType.Integer);
Assert.AreEqual (null, p2.Value, "#10");
Assert.AreEqual (DbType.Int32, p2.DbType, "#11");
Assert.AreEqual (NpgsqlDbType.Integer, p2.NpgsqlDbType, "#12");
//Although a NpgsqlDbType is specified, calling ResetSqlDbType resets
//the NpgsqlDbType and DbType properties to default values
p2.ResetSqlDbType ();
Assert.AreEqual (DbType.String, p2.DbType, "#13 Resetting NpgsqlDbType must infer the type from the value");
Assert.AreEqual (NpgsqlDbType.Text, p2.NpgsqlDbType, "#14 Resetting NpgsqlDbType must infer the type from the value");
p2.NpgsqlDbType = NpgsqlDbType.Timestamp; //assigning a NpgsqlDbType
Assert.AreEqual (DbType.DateTime, p2.DbType, "#15");
Assert.AreEqual (NpgsqlDbType.Timestamp, p2.NpgsqlDbType, "#16");
p2.ResetSqlDbType (); //Resetting NpgsqlDbType
Assert.AreEqual (DbType.String, p2.DbType, "#17 Resetting NpgsqlDbType must infer the type from the value");
Assert.AreEqual (NpgsqlDbType.Text, p2.NpgsqlDbType, "#18 Resetting NpgsqlDbType must infer the type from the value");
}