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