{"record":{"id":"5620e195a6dfa2ef","repo":"tursodatabase/turso","slug":"parameter-value-not-found-5620e1","errorCode":null,"errorMessage":"Parameter {value} not found","messagePattern":"Parameter (.+?) not found","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoParameterCollection.cs","lineNumber":82,"sourceCode":"    {\n        return _parameters.FindIndex(p => value is TursoParameter ? p == value : p.Value == value);\n    }\n\n    public override int IndexOf(string parameterName)\n    {\n        return _parameters.FindIndex(p => p.ParameterName == parameterName);\n    }\n\n    public override void Insert(int index, object value)\n    {\n        _parameters.Insert(index, value as TursoParameter ?? new TursoParameter(value));\n    }\n\n    public override void Remove(object value)\n    {\n        var index = IndexOf(value);\n        if (index == -1)\n            throw new ArgumentException($\"Parameter {value} not found\");\n        _parameters.RemoveAt(index);\n    }\n\n    public override void RemoveAt(int index)\n    {\n        _parameters.RemoveAt(index);\n    }\n\n    public override void RemoveAt(string parameterName)\n    {\n        var index = IndexOf(parameterName);\n        if (index == -1)\n            throw new ArgumentException($\"Parameter {parameterName} not found\");\n\n        _parameters.RemoveAt(index);\n    }\n\n    protected override DbParameter GetParameter(int index)","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data/TursoParameterCollection.cs#L64-L100","documentation":"TursoParameterCollection.Remove(object) throws this ArgumentException when the value cannot be found in the collection (IndexOf returns -1). Lookup is by the stored TursoParameter instances/names, so removing a freshly constructed parameter that merely looks equal, or passing a raw string name, will not match.","triggerScenarios":"Calling cmd.Parameters.Remove(new TursoParameter(\"@id\", 1)) instead of removing the instance that was added; calling Remove(someString) expecting name-based removal; removing a parameter that was already removed or belongs to a different command.","commonSituations":"Helper methods that rebuild parameters to remove them; retry loops that clear/re-add parameters and then remove stale references; mixing up Remove(object) with RemoveAt(string) from other collection APIs.","solutions":["Remove by name instead: cmd.Parameters.RemoveAt(\"@id\").","Or keep and pass the exact instance you added when using Remove(instance).","Check cmd.Parameters.IndexOf(name) != -1 (or Contains) before removing in conditional cleanup code."],"exampleFix":"// before\ncmd.Parameters.Remove(new TursoParameter(\"@id\", 1)); // new instance -> not found\n\n// after\ncmd.Parameters.RemoveAt(\"@id\");","handlingStrategy":"validation","validationCode":"if (cmd.Parameters.IndexOf(parameter.ParameterName) != -1)\n    cmd.Parameters.Remove(parameter);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer RemoveAt(name) over Remove(instance) unless you hold the exact added instance.","Never construct a look-alike parameter just to remove it."],"tags":["csharp","dotnet","parameters","collection","api-misuse"],"backgroundTag":"parameter-not-found","analyzedSha":"244cde92a7df7f9b8b8b7a4075c35a12977e303e","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}