{"record":{"id":"01cfece700a623cc","repo":"tursodatabase/turso","slug":"unsupported-argument-type-value-gettype","errorCode":null,"errorMessage":"Unsupported argument type: {value.GetType()}","messagePattern":"Unsupported argument type: (.+?)","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"bindings/dotnet/src/Turso.Serverless.Client/HranaProtocol.cs","lineNumber":65,"sourceCode":"                return new HranaValue { Type = \"float\", DoubleValue = (double)m };\n            case string s:\n                return new HranaValue { Type = \"text\", StringValue = s };\n            case char c:\n                return new HranaValue { Type = \"text\", StringValue = c.ToString() };\n            case Guid g:\n                return new HranaValue { Type = \"text\", StringValue = g.ToString() };\n            case DateTime dt:\n                return new HranaValue { Type = \"text\", StringValue = dt.ToString(\"o\", CultureInfo.InvariantCulture) };\n            case DateTimeOffset dto:\n                return new HranaValue { Type = \"text\", StringValue = dto.ToString(\"o\", CultureInfo.InvariantCulture) };\n            case byte[] bytes:\n                return new HranaValue { Type = \"blob\", BlobValue = bytes };\n            case ReadOnlyMemory<byte> memory:\n                return new HranaValue { Type = \"blob\", BlobValue = memory.ToArray() };\n            case Memory<byte> memory:\n                return new HranaValue { Type = \"blob\", BlobValue = memory.ToArray() };\n            default:\n                throw new ArgumentException($\"Unsupported argument type: {value.GetType()}\");\n        }\n    }\n\n    public object? Decode()\n    {\n        return Type switch\n        {\n            \"null\" => null,\n            \"integer\" => long.Parse(StringValue!, CultureInfo.InvariantCulture),\n            \"float\" => DoubleValue ?? 0d,\n            \"text\" => StringValue,\n            \"blob\" => BlobValue ?? [],\n            _ => null,\n        };\n    }\n}\n\ninternal sealed class HranaValueConverter : JsonConverter<HranaValue>","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/tursodatabase/turso/blob/244cde92a7df7f9b8b8b7a4075c35a12977e303e/bindings/dotnet/src/Turso.Serverless.Client/HranaProtocol.cs#L47-L83","documentation":"The client maps CLR objects to Hrana types via an explicit pattern match over a fixed set: null/DBNull, bool, integer types, float, double, decimal, string, char, Guid, DateTime, DateTimeOffset, byte[], and (ReadOnly)Memory<byte>. Any other runtime type falls to the default case and throws, naming the actual type in the message.","triggerScenarios":"Binding DateOnly, TimeOnly, TimeSpan, UInt128/Int128, an enum boxed as object, or a custom POCO via AddWithValue or a parameter dictionary. E.g. cmd.Parameters.AddWithValue(\"@d\", new DateOnly(2026,1,1)).","commonSituations":"Newer BCL types the client version predates; enums arriving from generic code boxed as object; passing LINQ projections or anonymous objects as parameter values instead of their scalar properties.","solutions":["Convert the value to a supported type before binding: dateOnly.ToString(\"o\"), timeSpan.TotalSeconds, (int)enumValue, poco.SomeProperty","For byte-like data use byte[] or ReadOnlyMemory<byte>","Update the Turso.Serverless.Client package — the supported set expands between releases","Wrap unsupported types in a small ToHranaValue helper so conversions live in one place"],"exampleFix":"// before\ncmd.Parameters.AddWithValue(\"@date\", new DateOnly(2026, 8, 20)); // throws\n\n// after\ncmd.Parameters.AddWithValue(\"@date\", new DateOnly(2026, 8, 20).ToString(\"o\", CultureInfo.InvariantCulture));","handlingStrategy":"validation","validationCode":"static readonly HashSet<Type> Supported = new(){ typeof(bool), typeof(sbyte), typeof(byte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal), typeof(string), typeof(char), typeof(Guid), typeof(DateTime), typeof(DateTimeOffset), typeof(byte[]) };\nif (value is not null && !Supported.Contains(value.GetType())) value = Convert.ToString(value, CultureInfo.InvariantCulture);","typeGuard":"static bool IsSupportedHranaValue(object? value) => value is null or DBNull or bool or sbyte or byte or short or ushort or int or uint or long or ulong or float or double or decimal or string or char or Guid or DateTime or DateTimeOffset or byte[] or ReadOnlyMemory<byte> or Memory<byte>;","tryCatchPattern":"try { cmd.Parameters.AddWithValue(\"@p\", value); } catch (ArgumentException ex) when (ex.Message.StartsWith(\"Unsupported argument type\")) { cmd.Parameters.AddWithValue(\"@p\", value!.ToString()); }","preventionTips":["Centralize parameter creation in one helper that converts unsupported types","Convert DateOnly/TimeOnly/TimeSpan/enum values explicitly at the call site","Watch client release notes for newly supported types and update the package before relying on them"],"tags":["csharp","dotnet","type-mapping","parameter-binding"],"backgroundTag":"unsupported-parameter-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"}