{"record":{"id":"66a8e06f532e8052","repo":"tursodatabase/turso","slug":"tursobatchcommand-only-supports-commandtype-text-66a8e0","errorCode":null,"errorMessage":"TursoBatchCommand only supports CommandType.Text.","messagePattern":"TursoBatchCommand only supports CommandType\\.Text\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Data/TursoBatchCommand.cs","lineNumber":36,"sourceCode":"    public TursoBatchCommand(string commandText)\n    {\n        CommandText = commandText;\n    }\n\n    [AllowNull]\n    public override string CommandText\n    {\n        get => _commandText;\n        set => _commandText = value ?? \"\";\n    }\n\n    public override CommandType CommandType\n    {\n        get => _commandType;\n        set\n        {\n            if (value != CommandType.Text)\n                throw new NotSupportedException(\"TursoBatchCommand only supports CommandType.Text.\");\n\n            _commandType = value;\n        }\n    }\n\n    protected override DbParameterCollection DbParameterCollection => _parameters;\n\n    public new TursoParameterCollection Parameters => _parameters;\n\n    public override int RecordsAffected => _recordsAffected;\n\n    public override bool CanCreateParameter => true;\n\n    public override DbParameter CreateParameter()\n    {\n        return new TursoParameter();\n    }\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Data/TursoBatchCommand.cs#L18-L54","documentation":"TursoBatchCommand is the per-statement entry inside a TursoBatch, and the Turso engine only executes raw SQL text. The CommandType setter accepts only CommandType.Text and throws NotSupportedException for StoredProcedure or TableDirect because there is no stored-procedure catalog to invoke. The getter always reports Text.","triggerScenarios":"Assigning batchCommand.CommandType = CommandType.StoredProcedure or CommandType.TableDirect on an item obtained from a TursoBatch.Commands collection (TursoBatchCommand.cs:30-38).","commonSituations":"Porting Microsoft.Data.SqlClient batch code that calls stored procedures via CommandType.StoredProcedure; generic ADO.NET helpers or ORM interceptors that set CommandType on every DbBatchCommand regardless of provider; DI configuration that assumes SqlClient semantics.","solutions":["Remove the CommandType assignment; Text is the default and the getter always returns Text.","Replace the stored-procedure call with the equivalent inline SQL in CommandText (e.g. EXEC or the full statement body).","In provider-agnostic helper code, only assign CommandType when the concrete provider supports values other than Text."],"exampleFix":"// before\nvar cmd = batch.Commands.Add(new TursoBatchCommand());\ncmd.CommandText = \"usp_GetUser\";\ncmd.CommandType = CommandType.StoredProcedure; // throws NotSupportedException\n\n// after\nvar cmd = batch.Commands.Add(new TursoBatchCommand());\ncmd.CommandText = \"SELECT * FROM users WHERE id = @id\"; // CommandType.Text is the default","handlingStrategy":"validation","validationCode":"var desired = CommandType.StoredProcedure;\nif (cmd is TursoBatchCommand && desired != CommandType.Text)\n{\n    // TursoBatchCommand only supports Text; inline the SQL instead of assigning.\n    throw new NotSupportedException($\"Cannot set {desired} on a TursoBatchCommand; use inline SQL.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    cmd.CommandType = CommandType.StoredProcedure;\n}\ncatch (NotSupportedException)\n{\n    // Provider only supports Text: rewrite as inline SQL in CommandText.\n}","preventionTips":["Never set CommandType explicitly unless the provider documents support for it.","Replace stored-procedure calls with inline SQL before adopting Turso.","Keep provider-specific property assignments out of shared DbBatchCommand helper code."],"tags":["dotnet","ado-net","tursodb","batch","commandtype","stored-procedure"],"backgroundTag":"unsupported-command-type","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"}