Hi currently have the problem, that I want to insert values in a postgres database where the table contains self defined types like.
CREATE TYPE TestEnum AS ENUM ('Value1','Value2');
When I try to add a parameter in C# I always get an error because of the wrong NpgsqlDbType. So my question is what NpgsqlDbType to use for such self defined Types.
var parameter = new NpgsqlParameter(":p1", NpgsqlDbType.????)
{
Value = "Value1",
Direction = ParameterDirection.Input
}
Thanks for your help. I'm really going mad because of this problem.
After all, I found a solution that solves the problem, although it's not the real solution. I now add a NpgsqlDbType.Varchar parameter and add a CAST(:p1 as "TestEnum") to the SQL
e.g.
INSERT INTO tableName (Col) VALUES ( CAST(:p1 as "TestEnum") )
It works for me, although I do not think that this is a very nice solution due to the cast. If someone will find a better solution in future, please drop me a line. ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With