You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The NpgsqlParameterCollection docs inherit misleading Add(object) docs #6150
However, you're not adding the Value of the DbParameter, you should be adding a NpgsqlParameter
varcmd=newNpgsqlCommand("select * from foo where id = $1");// workscmd.Parameters.Add(newNpgsqlParameter(){Value=1});// throws System.InvalidCastException: The value "1" is not of type "NpgsqlParameter" and cannot be used in this parameter collection.cmd.Parameters.Add(1);
I understand there are more idiomatic ways of doing things, but since ADO.NET tends to allow many ways of doing something, I'd propose that the docs call out that it must be an instance of NpgsqlParameter.
It's not exactly misleading, DbParameter is an abstract class after all. I do agree it's not as detailed as it ideally should be. I will mark it as an enhancement for whenever we'll get to it, PRs are also welcome.
Activity
NinoFloris commentedon Jul 28, 2025
It's not exactly misleading, DbParameter is an abstract class after all. I do agree it's not as detailed as it ideally should be. I will mark it as an enhancement for whenever we'll get to it, PRs are also welcome.
Fix NpgsqlParameterCollection.Add(object) documentation (npgsql#6150)
Docs: clarify Add(object)/Insert(object) require NpgsqlParameter (fixes
NinoFloris commentedon Mar 13, 2026
Fixed by #6342