本文整理汇总了C#中Npgsql.NpgsqlConnection.ReloadTypes方法的典型用法代码示例。如果您正苦于以下问题:C# NpgsqlConnection.ReloadTypes方法的具体用法?C# NpgsqlConnection.ReloadTypes怎么用?C# NpgsqlConnection.ReloadTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Npgsql.NpgsqlConnection
的用法示例。
在下文中一共展示了NpgsqlConnection.ReloadTypes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReloadTypes
public void ReloadTypes()
{
using (var conn = new NpgsqlConnection(ConnectionString))
{
conn.Open();
Assert.That(ExecuteScalar("SELECT EXISTS (SELECT * FROM pg_type WHERE typname='reload_types_enum')"), Is.False);
ExecuteNonQuery("CREATE TYPE pg_temp.reload_types_enum AS ENUM ('First', 'Second')");
conn.ReloadTypes();
conn.RegisterEnum<ReloadTypesEnum>("reload_types_enum");
}
}
示例2: ReadUnmappedEnumsAsString
public void ReadUnmappedEnumsAsString()
{
using (var conn = new NpgsqlConnection(ConnectionString))
{
conn.Open();
ExecuteNonQuery("CREATE TYPE pg_temp.mood AS ENUM ('Sad', 'Ok', 'Happy')", conn);
conn.ReloadTypes();
using (var cmd = new NpgsqlCommand("SELECT 'Sad'::MOOD, ARRAY['Ok', 'Happy']::MOOD[]", conn))
using (var reader = cmd.ExecuteReader())
{
reader.Read();
Assert.That(reader[0], Is.EqualTo("Sad"));
Assert.That(reader[1], Is.EqualTo(new[] { "Ok", "Happy" }));
}
}
}
示例3: ReadUnmappedEnumsAsString
public void ReadUnmappedEnumsAsString()
{
using (var conn = new NpgsqlConnection(ConnectionString))
{
conn.Open();
conn.ExecuteNonQuery("CREATE TYPE pg_temp.mood7 AS ENUM ('Sad', 'Ok', 'Happy')");
conn.ReloadTypes();
using (var cmd = new NpgsqlCommand("SELECT 'Sad'::MOOD7, ARRAY['Ok', 'Happy']::MOOD7[]", conn))
using (var reader = cmd.ExecuteReader())
{
reader.Read();
Assert.That(reader[0], Is.EqualTo("Sad"));
Assert.That(reader.GetDataTypeName(0), Does.StartWith("pg_temp").And.EndsWith("mood7"));
Assert.That(reader[1], Is.EqualTo(new[] { "Ok", "Happy" }));
}
}
}