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 blob, DataStax does not recommend using blob in primary keys.

You can insert binary data as a byte array.

The C# client automatically converts byte[] values into a Base64-encoded string.

  • Typed

  • Untyped

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);
  }
}
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);
  }
}

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM