BLOB type (C#)
Use the blob type for binary data.
Although you can store binary-encoded vector data in a blob column, you cannot create a vector index or perform a vector search on the column.
Instead, use the vector type to store vector data.
|
Due to a known issue with filtering on |
You can insert binary data as a byte array.
The C# client automatically converts byte[] values into a Base64-encoded string.
- Typed
-
using DataStax.AstraDB.DataApi; using DataStax.AstraDB.DataApi.Core; using DataStax.AstraDB.DataApi.Tables; namespace Examples; public class ExampleRow { [ColumnPrimaryKey] [ColumnName("title")] public string Title { get; set; } = null!; [ColumnName("example_blob")] public byte[]? ExampleBlob { get; set; } } public class Program { static async Task Main() { // Get an existing table var client = new DataAPIClient( new CommandOptions() { Destination = DataAPIDestination.HCD } ); var database = client.GetDatabase( "API_ENDPOINT", DataAPIClient.UsernamePasswordTokenProvider( "USERNAME", "PASSWORD" ), "KEYSPACE_NAME" ); var table = database.GetTable<ExampleRow>("TABLE_NAME"); // Insert a binary value var row = new ExampleRow() { ExampleBlob = new byte[] { 0x3D, 0xFB, 0xE7, 0x6D, 0x3E, 0xE9, 0x78, 0xD5, 0x3F, 0x49, 0xFB, 0xE7, }, Title = "Example", }; await table.InsertOneAsync(row); } } - Untyped
-
using DataStax.AstraDB.DataApi; using DataStax.AstraDB.DataApi.Core; using DataStax.AstraDB.DataApi.Tables; namespace Examples; public class Program { static async Task Main() { // Get an existing table var client = new DataAPIClient( new CommandOptions() { Destination = DataAPIDestination.HCD } ); var database = client.GetDatabase( "API_ENDPOINT", DataAPIClient.UsernamePasswordTokenProvider( "USERNAME", "PASSWORD" ), "KEYSPACE_NAME" ); var table = database.GetTable("TABLE_NAME"); // Insert a binary value var row = new Row() { { "example_blob", new byte[] { 0x3D, 0xFB, 0xE7, 0x6D, 0x3E, 0xE9, 0x78, 0xD5, 0x3F, 0x49, 0xFB, 0xE7, } }, { "title", "Example" }, }; await table.InsertOneAsync(row); } }