-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed as not planned
Description
Description
For a special case I want to use a derivation from SqliteParameterCollection to be used in a derivation of SqliteCommand. For this I override the virtual Parameters property of SqliteCommand.
If doing so I get an exception when a command uses parameters (see stack trace).
When I add the parameters also to be base class parameters, it works fine.
It seems the SqliteCommand does not use the property for internal access to the collection. But if so, I don't see why the property itself is virtual?!
Include your code
public class MySqliteParameterCollection : SqliteParameterCollection
{
// some methods here...
}
public class MySqliteCommand : SqliteCommand
{
private MySqliteParameterCollection parameters;
public override SqliteParameterCollection Parameters
=> this.parameters ??= new MySqliteParameterCollection();
// some methods here...
}Include stack traces
System.InvalidOperationException: Must add values for the following parameters: @key, @value
at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
Include version information
Microsoft.Data.Sqlite version: 6.03
Target framework: .NET 5.0
Operating system: Windows 10 64 Bit