本文整理汇总了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");
}