Overview

This C# Client Library simplifies using the DataStax Data API to manage and interact with Astra DB instances as well as other DataStax databases.

Installation

dotnet add package DataStax.AstraDB.DataApi --prerelease

Quickstart

//instantiate a client
var client = new DataAPIClient("YourTokenHere");

//connect to a database
var database = client.GetDatabase("YourAPIEndpointHere");

//create a new collection
var collection = await database.CreateCollectionAsync<SimpleObject>("YourCollectionNameHere");

//insert a document into the collection
var documents = new List<SimpleObject>
{
    new SimpleObject()
    {
        Name = "Test Object 1",
    },
    new SimpleObject()
    {
        Name = "Test Object 2",
    }
};
var insertResult = await collection.InsertManyAsync(documents);

//find documents
var filter = Builders<SimpleObject>.CollectionFilter.Eq(so => so.Name, "Test Object 1");
var cursor = collection.Find(filter);
await foreach (var doc in cursor)
{
    // Process 'doc''
}