Table of Contents

Class Database

Namespace
DataStax.AstraDB.DataApi.Core
Assembly
DataStax.AstraDB.DataApi.dll

Entrypoint for the interactions with a specific database such as creating/deleting collections/tables, connecting to collections/tables, and executing arbitrary commands.

Note that creating an instance of a Database doesn't trigger actual database creation; the database must have already existed beforehand. If you need to create a new database, use the AstraAdmin class.

public class Database
Inheritance
Database
Inherited Members

Examples

Using the default keyspace for all operations

var client = new DataAPIClient("token");
var database = client.GetDatabase("https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com");
// Check to see if a collection exists in the default keyspace
var doesCollectionExist = database.DoesCollectionExist("myCollection");

Setting a custom keyspace for all operations

var client = new DataAPIClient("token");
var options = new GetDatabaseOptions() { Keyspace = "myKeyspace" };
var database = client.GetDatabase("https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com", options);
// Check to see if a collection exists in the custom keyspace
var doesCollectionExist = database.DoesCollectionExist("myCollectionInMyKeyspace");

Setting a custom keyspace for a single operation

var client = new DataAPIClient("token");
var database = client.GetDatabase("https://01234567-89ab-cdef-0123-456789abcdef-us-east1.apps.astra.datastax.com");
// Check to see if a collection exists in the custom keyspace
var options = new DoesCollectionExistOptions() { Keyspace = "myKeyspace" };
var doesCollectionExist = database.DoesCollectionExist("myCollectionInMyKeyspace", options);

Remarks

The Database class has a concept of a "current keyspace", which is the keyspace used for all operations. This can be overridden in each method call by passing the adequate 'options' parameter, or when creating the Database instance (see GetDatabase(string, GetDatabaseOptions)). If unset, the default keyspace will be used.

Properties

Id

The database Guid (as a string). If no Guid is known, an empty string is returned.

public string Id { get; }

Property Value

string

Keyspace

The working keyspace for this database. Unless otherwise specified, this keyspace will be targeted when invoking a method.

public string Keyspace { get; }

Property Value

string

Methods

AlterType(string, IAlterTypeOperation, AlterTypeOptions)

public void AlterType(string typeName, IAlterTypeOperation operation, AlterTypeOptions options = null)

Parameters

typeName string

The name of the User Defined Type to alter.

operation IAlterTypeOperation

The operation to apply to the User Defined Type.

options AlterTypeOptions

AlterTypeAsync(string, IAlterTypeOperation, AlterTypeOptions)

Alter a User Defined Type given the type name and IAlterTypeOperation

public Task AlterTypeAsync(string typeName, IAlterTypeOperation operation, AlterTypeOptions options = null)

Parameters

typeName string

The name of the User Defined Type to alter.

operation IAlterTypeOperation

The operation to apply to the User Defined Type.

options AlterTypeOptions

Returns

Task

AlterTypeAsync<T>(IAlterTypeOperation, AlterTypeOptions)

Alter a User Defined Type by specifying the class that defines the type

public Task AlterTypeAsync<T>(IAlterTypeOperation operation, AlterTypeOptions options = null) where T : new()

Parameters

operation IAlterTypeOperation

The operation to apply to the User Defined Type.

options AlterTypeOptions

Returns

Task

Type Parameters

T

The type that defines the User Defined Type

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used.

AlterType<T>(IAlterTypeOperation, AlterTypeOptions)

public void AlterType<T>(IAlterTypeOperation operation, AlterTypeOptions options = null) where T : new()

Parameters

operation IAlterTypeOperation

The operation to apply to the User Defined Type.

options AlterTypeOptions

Type Parameters

T

The type that defines the User Defined Type

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used.

CreateCollection(string, CollectionDefinition, CreateCollectionOptions)

public Collection<Document> CreateCollection(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null)

Parameters

collectionName string

The name of the collection to create.

definition CollectionDefinition

Configuration for the collection.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<Document>

A reference to the created collection.

Remarks

This version uses a simple Dictionary<TKey, TValue>for the documents stored in the collection. See the Document class. Use the strongly-typed overloads to specify a custom document type, for example CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions).

CreateCollection(string, CreateCollectionOptions)

public Collection<Document> CreateCollection(string collectionName, CreateCollectionOptions options = null)

Parameters

collectionName string

The name of the collection to create.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<Document>

A reference to the created collection.

Remarks

This version uses a simple Dictionary<TKey, TValue>for the documents stored in the collection. See the Document class. Use the strongly-typed overloads to specify a custom document type, for example CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions).

CreateCollectionAsync(string, CollectionDefinition, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter.

public Task<Collection<Document>> CreateCollectionAsync(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null)

Parameters

collectionName string

The name of the collection to create.

definition CollectionDefinition

Configuration for the collection.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<Document>>

A reference to the created collection.

Remarks

This version uses a simple Dictionary<TKey, TValue>for the documents stored in the collection. See the Document class. Use the strongly-typed overloads to specify a custom document type, for example CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions).

CreateCollectionAsync(string, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter.

public Task<Collection<Document>> CreateCollectionAsync(string collectionName, CreateCollectionOptions options = null)

Parameters

collectionName string

The name of the collection to create.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<Document>>

A reference to the created collection.

Remarks

This version uses a simple Dictionary<TKey, TValue>for the documents stored in the collection. See the Document class. Use the strongly-typed overloads to specify a custom document type, for example CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions).

CreateCollectionAsync<T>(CollectionDefinition, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T>> CreateCollectionAsync<T>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollectionAsync<T>(CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T>> CreateCollectionAsync<T>(CreateCollectionOptions options = null) where T : class

Parameters

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollectionAsync<T>(string, CollectionDefinition, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T>> CreateCollectionAsync<T>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollectionAsync<T>(string, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T>> CreateCollectionAsync<T>(string collectionName, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollectionAsync<T, TId>(CollectionDefinition, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T, TId>> CreateCollectionAsync<T, TId>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T, TId>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollectionAsync<T, TId>(CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T, TId>> CreateCollectionAsync<T, TId>(CreateCollectionOptions options = null) where T : class

Parameters

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T, TId>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T, TId>> CreateCollectionAsync<T, TId>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T, TId>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollectionAsync<T, TId>(string, CreateCollectionOptions)

Create a new collection in the database. The collection is created in the database's working keyspace, unless this is overridden through the options parameter. Unless explicit parameters are provided, the name and configuration are extracted from the document type class.

public Task<Collection<T, TId>> CreateCollectionAsync<T, TId>(string collectionName, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Task<Collection<T, TId>>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollection<T>(CollectionDefinition, CreateCollectionOptions)

public Collection<T> CreateCollection<T>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollection<T>(CreateCollectionOptions)

public Collection<T> CreateCollection<T>(CreateCollectionOptions options = null) where T : class

Parameters

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollection<T>(string, CollectionDefinition, CreateCollectionOptions)

public Collection<T> CreateCollection<T>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollection<T>(string, CreateCollectionOptions)

public Collection<T> CreateCollection<T>(string collectionName, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

CreateCollection<T, TId>(CollectionDefinition, CreateCollectionOptions)

public Collection<T, TId> CreateCollection<T, TId>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T, TId>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollection<T, TId>(CreateCollectionOptions)

public Collection<T, TId> CreateCollection<T, TId>(CreateCollectionOptions options = null) where T : class

Parameters

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T, TId>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollection<T, TId>(string, CollectionDefinition, CreateCollectionOptions)

public Collection<T, TId> CreateCollection<T, TId>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

definition CollectionDefinition

Configuration for the collection, overriding the information from the document type.

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T, TId>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateCollection<T, TId>(string, CreateCollectionOptions)

public Collection<T, TId> CreateCollection<T, TId>(string collectionName, CreateCollectionOptions options = null) where T : class

Parameters

collectionName string

The name of the collection to create, overriding the information from the document type

options CreateCollectionOptions

Options for the collection, such as API keys, keyspace override, or timeouts.

Returns

Collection<T, TId>

A reference to the created collection.

Type Parameters

T

The type to use for the document.

TId

The type to use for the document id.

CreateTable(string, TableDefinition, CreateTableOptions)

public Table<Row> CreateTable(string tableName, TableDefinition definition, CreateTableOptions options = null)

Parameters

tableName string

The name to give the table.

definition TableDefinition

The table definition describing columns and primary key.

options CreateTableOptions

Options for the create table command.

Returns

Table<Row>

A Table<T> instance for the created table.

CreateTableAsync(string, TableDefinition, CreateTableOptions)

Creates a table with the specified name, definition, and options.

public Task<Table<Row>> CreateTableAsync(string tableName, TableDefinition definition, CreateTableOptions options = null)

Parameters

tableName string

The name to give the table.

definition TableDefinition

The table definition describing columns and primary key.

options CreateTableOptions

Options for the create table command.

Returns

Task<Table<Row>>

A Table<T> instance for the created table.

CreateTableAsync<TRow>(CreateTableOptions)

Creates a table using the schema inferred from the TRow type. Any required user-defined type is created as well.

public Task<Table<TRow>> CreateTableAsync<TRow>(CreateTableOptions options = null) where TRow : class, new()

Parameters

options CreateTableOptions

Options for the create table command.

Returns

Task<Table<TRow>>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTableAsync<TRow>(TableDefinition, CreateTableOptions)

Creates a table with a name inferred from the TRow type. Any required user-defined type is created as well.

public Task<Table<TRow>> CreateTableAsync<TRow>(TableDefinition definition, CreateTableOptions options = null) where TRow : class, new()

Parameters

definition TableDefinition

A table definition, replacing that inferred from TRow.

options CreateTableOptions

Options for the create table command.

Returns

Task<Table<TRow>>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTableAsync<TRow>(string, CreateTableOptions)

Creates a table with the specified name using the schema inferred from the TRow type. Any required user-defined type is created as well.

public Task<Table<TRow>> CreateTableAsync<TRow>(string tableName, CreateTableOptions options = null) where TRow : class, new()

Parameters

tableName string

The name to give the table.

options CreateTableOptions

Options for the create table command.

Returns

Task<Table<TRow>>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTableAsync<TRow>(string, TableDefinition, CreateTableOptions)

Creates a table with the specified name and definitions. Any required user-defined type is created as well.

public Task<Table<TRow>> CreateTableAsync<TRow>(string tableName, TableDefinition definition, CreateTableOptions options = null) where TRow : class

Parameters

tableName string

The name to give the table.

definition TableDefinition

A table definition, replacing that inferred from TRow.

options CreateTableOptions

Options for the create table command.

Returns

Task<Table<TRow>>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTable<TRow>(CreateTableOptions)

public Table<TRow> CreateTable<TRow>(CreateTableOptions options = null) where TRow : class, new()

Parameters

options CreateTableOptions

Options for the create table command.

Returns

Table<TRow>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTable<TRow>(TableDefinition, CreateTableOptions)

public Table<TRow> CreateTable<TRow>(TableDefinition definition, CreateTableOptions options = null) where TRow : class, new()

Parameters

definition TableDefinition

A table definition, replacing that inferred from TRow.

options CreateTableOptions

Options for the create table command.

Returns

Table<TRow>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTable<TRow>(string, CreateTableOptions)

public Table<TRow> CreateTable<TRow>(string tableName, CreateTableOptions options = null) where TRow : class, new()

Parameters

tableName string

The name to give the table.

options CreateTableOptions

Options for the create table command.

Returns

Table<TRow>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateTable<TRow>(string, TableDefinition, CreateTableOptions)

public Table<TRow> CreateTable<TRow>(string tableName, TableDefinition definition, CreateTableOptions options = null) where TRow : class

Parameters

tableName string

The name to give the table.

definition TableDefinition

A table definition, replacing that inferred from TRow.

options CreateTableOptions

Options for the create table command.

Returns

Table<TRow>

A Table<T> instance for the created table.

Type Parameters

TRow

The type representing the table row schema.

CreateType(string, UserDefinedTypeDefinition, CreateTypeOptions)

public void CreateType(string typeName, UserDefinedTypeDefinition definition, CreateTypeOptions options = null)

Parameters

typeName string

The name of the type to create

definition UserDefinedTypeDefinition

The type definition

options CreateTypeOptions

CreateTypeAsync(string, UserDefinedTypeDefinition, CreateTypeOptions)

Create a User Defined Type dynamically by specifying its name and definition

public Task CreateTypeAsync(string typeName, UserDefinedTypeDefinition definition, CreateTypeOptions options = null)

Parameters

typeName string

The name of the type to create

definition UserDefinedTypeDefinition

The type definition

options CreateTypeOptions

Returns

Task

CreateTypeAsync<T>(CreateTypeOptions)

Create a User Defined Type dynamically by specifying the class that defines the type

public Task CreateTypeAsync<T>(CreateTypeOptions options = null)

Parameters

options CreateTypeOptions

Returns

Task

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used. Columns that do not match available types (GetDataAPIType(Type)) will be ignored. If properties include a ColumnNameAttribute attribute, that name will be used, otherwise the name of the property itself will be used.

CreateTypeAsync<T>(string, CreateTypeOptions)

Create a User Defined Type dynamically by specifying the class that defines the type

public Task CreateTypeAsync<T>(string typeName, CreateTypeOptions options = null)

Parameters

typeName string

The name of the type to create (overrides the name extracted from the provided class)

options CreateTypeOptions

Returns

Task

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used. Columns that do not match available types (GetDataAPIType(Type)) will be ignored. If properties include a ColumnNameAttribute attribute, that name will be used, otherwise the name of the property itself will be used.

CreateType<T>(CreateTypeOptions)

public void CreateType<T>(CreateTypeOptions options = null)

Parameters

options CreateTypeOptions

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used. Columns that do not match available types (GetDataAPIType(Type)) will be ignored. If properties include a ColumnNameAttribute attribute, that name will be used, otherwise the name of the property itself will be used.

CreateType<T>(string, CreateTypeOptions)

public void CreateType<T>(string typeName, CreateTypeOptions options = null)

Parameters

typeName string
options CreateTypeOptions

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used. Columns that do not match available types (GetDataAPIType(Type)) will be ignored. If properties include a ColumnNameAttribute attribute, that name will be used, otherwise the name of the property itself will be used.

DoesCollectionExist(string, DoesCollectionExistOptions)

public bool DoesCollectionExist(string collectionName, DoesCollectionExistOptions options = null)

Parameters

collectionName string
options DoesCollectionExistOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

bool

True if the collection exists, false otherwise.

DoesCollectionExistAsync(string, DoesCollectionExistOptions)

Looks to see if a collection exists in the database.

public Task<bool> DoesCollectionExistAsync(string collectionName, DoesCollectionExistOptions options = null)

Parameters

collectionName string
options DoesCollectionExistOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<bool>

True if the collection exists, false otherwise.

DoesTableExist(string, DoesTableExistOptions)

public bool DoesTableExist(string tableName, DoesTableExistOptions options = null)

Parameters

tableName string
options DoesTableExistOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

bool

True if the table exists, false otherwise.

DoesTableExistAsync(string, DoesTableExistOptions)

Looks to see if a table exists in the database.

public Task<bool> DoesTableExistAsync(string tableName, DoesTableExistOptions options = null)

Parameters

tableName string
options DoesTableExistOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<bool>

True if the table exists, false otherwise.

DropCollection(string, DropCollectionOptions)

public void DropCollection(string collectionName, DropCollectionOptions options = null)

Parameters

collectionName string
options DropCollectionOptions

DropCollectionAsync(string, DropCollectionOptions)

Remove a collection from the database.

public Task DropCollectionAsync(string collectionName, DropCollectionOptions options = null)

Parameters

collectionName string

The collection to remove

options DropCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task

DropCollectionAsync<T>(DropCollectionOptions)

Remove a collection from the database based on the class for its documents.

public Task DropCollectionAsync<T>(DropCollectionOptions options = null)

Parameters

options DropCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task

Type Parameters

T

The type of the document stored in the referenced collection. The name of the collection to drop is extracted from this.

DropCollection<T>(DropCollectionOptions)

public void DropCollection<T>(DropCollectionOptions options = null)

Parameters

options DropCollectionOptions

Type Parameters

T

The type of the document stored in the referenced collection

DropTable(string, DropTableOptions)

public void DropTable(string tableName, DropTableOptions options = null)

Parameters

tableName string
options DropTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

DropTableAsync(string, DropTableOptions)

Drops the table with the specified name.

public Task DropTableAsync(string tableName, DropTableOptions options = null)

Parameters

tableName string
options DropTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task

DropTableAsync<TRow>(DropTableOptions)

Drops the table with the name defined by a [TableName] attribute on the TRowtype, or the type name if no attribute is present.

public Task DropTableAsync<TRow>(DropTableOptions options = null) where TRow : class, new()

Parameters

options DropTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task

Type Parameters

TRow

DropTableIndex(string, DropTableIndexOptions)

public void DropTableIndex(string indexName, DropTableIndexOptions options = null)

Parameters

indexName string
options DropTableIndexOptions

The options to use for the command, useful for overriding the keyspace, for example.

DropTableIndexAsync(string, DropTableIndexOptions)

Drops an index on the table.

public Task DropTableIndexAsync(string indexName, DropTableIndexOptions options = null)

Parameters

indexName string
options DropTableIndexOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task

DropTable<TRow>(DropTableOptions)

public void DropTable<TRow>(DropTableOptions options = null) where TRow : class, new()

Parameters

options DropTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Type Parameters

TRow

DropType(string, DropTypeOptions)

public void DropType(string typeName, DropTypeOptions options = null)

Parameters

typeName string

The name of the user-defined type to drop.

options DropTypeOptions

DropTypeAsync(string, DropTypeOptions)

Drop a User Defined Type dynamically by specifying the type name

public Task DropTypeAsync(string typeName, DropTypeOptions options = null)

Parameters

typeName string

The name of the user-defined type to drop.

options DropTypeOptions

Returns

Task

DropTypeAsync<T>(DropTypeOptions)

Drop a User Defined Type dynamically by specifying the class that defines the type

public Task DropTypeAsync<T>(DropTypeOptions options = null)

Parameters

options DropTypeOptions

Returns

Task

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used.

DropType<T>(DropTypeOptions)

Synchronous version of DropTypeAsync<T>(DropTypeOptions)

public void DropType<T>(DropTypeOptions options = null)

Parameters

options DropTypeOptions

Type Parameters

T

Remarks

If the class includes a UserDefinedTypeAttribute attribute, that name will be used, otherwise the name of the class itself will be used.

GetAdmin(GetAdminOptions)

Returns an instance of IDatabaseAdmin that can be used to perform database management operations for this database

public IDatabaseAdmin GetAdmin(GetAdminOptions options = null)

Parameters

options GetAdminOptions

Optional. The options for the admin, useful e.g. for customizing timeout settings

Returns

IDatabaseAdmin

An appropriate database admin instance

Remarks

The type-parameterized form of this method, GetAdmin<TAdmin>(GetAdminOptions), is recommended for a more type-safe code.

Exceptions

ArgumentException

Thrown when the options request a different destination

GetAdmin<TAdmin>(GetAdminOptions)

Returns an instance of TAdmin that can be used to perform database management operations for this database

public TAdmin GetAdmin<TAdmin>(GetAdminOptions options = null) where TAdmin : IDatabaseAdmin

Parameters

options GetAdminOptions

Optional. The options for the admin, useful e.g. for customizing timeout settings

Returns

TAdmin

An instance of the specified admin type

Type Parameters

TAdmin

The type of database admin to return. Must be either DatabaseAdminAstra or DatabaseAdminDataAPI

Exceptions

ArgumentException

Thrown when the options request a different destination, or when the resulting admin does not match the provided TAdmin

GetCollection(string, GetCollectionOptions)

Returns a reference to the collection with the specified name.

public Collection<Document> GetCollection(string collectionName, GetCollectionOptions options = null)

Parameters

collectionName string
options GetCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Collection<Document>

GetCollection<T>(GetCollectionOptions)

Returns a reference to the collection based on the specified document type. The collection name is determined by the CollectionNameAttribute on the document type, or the name of the document type if the attribute is not present.

public Collection<T> GetCollection<T>(GetCollectionOptions options = null) where T : class

Parameters

options GetCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Collection<T>

Type Parameters

T

The type of the document stored in the referenced collection

GetCollection<T>(string, GetCollectionOptions)

Returns a reference to the collection with the specified name.

public Collection<T> GetCollection<T>(string collectionName, GetCollectionOptions options = null) where T : class

Parameters

collectionName string
options GetCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Collection<T>

Type Parameters

T

The type of the document stored in the referenced collection

GetCollection<T, TId>(GetCollectionOptions)

Returns a reference to the collection based on the specified document type. The collection name is determined by the CollectionNameAttribute on the document type, or the name of the document type if the attribute is not present.

public Collection<T, TId> GetCollection<T, TId>(GetCollectionOptions options = null) where T : class

Parameters

options GetCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Collection<T, TId>

Type Parameters

T

The type of the document stored in the referenced collection

TId

The type to use for the document id.

GetCollection<T, TId>(string, GetCollectionOptions)

Returns a reference to the collection with the specified name.

public Collection<T, TId> GetCollection<T, TId>(string collectionName, GetCollectionOptions options = null) where T : class

Parameters

collectionName string
options GetCollectionOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Collection<T, TId>

Type Parameters

T
TId

GetTable(string, GetTableOptions)

Returns a reference to a table by name.

public Table<Row> GetTable(string tableName, GetTableOptions options = null)

Parameters

tableName string

The name of the table being targeted.

options GetTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Table<Row>

A table class allowing performing operations on the table.

GetTable<TRow>(GetTableOptions)

Returns a reference to the table with the name defined by a [TableName] attribute on the row type, or the type name if no attribute is present.

public Table<TRow> GetTable<TRow>(GetTableOptions options = null) where TRow : class, new()

Parameters

options GetTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Table<TRow>

A table class allowing performing operations on the table.

Type Parameters

TRow

The type of the rows in the table.

GetTable<TRow>(string, GetTableOptions)

Returns a reference to the table with the name defined by a [TableName] attribute on the row type, or the type name if no attribute is present.

public Table<TRow> GetTable<TRow>(string tableName, GetTableOptions options = null) where TRow : class

Parameters

tableName string

The name of the table - if provided, overrides the information found on the row type.

options GetTableOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Table<TRow>

A table class allowing performing operations on the table.

Type Parameters

TRow

The type of the rows in the table.

ListCollectionNames(ListCollectionNamesOptions)

public List<string> ListCollectionNames(ListCollectionNamesOptions options = null)

Parameters

options ListCollectionNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

List<string>

The list of collection names.

ListCollectionNamesAsync(ListCollectionNamesOptions)

Get a list of all collection names in the current keyspace.

public Task<List<string>> ListCollectionNamesAsync(ListCollectionNamesOptions options = null)

Parameters

options ListCollectionNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<List<string>>

The list of collection names.

ListCollections(ListCollectionsOptions)

public IEnumerable<CollectionInfo> ListCollections(ListCollectionsOptions options = null)

Parameters

options ListCollectionsOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

IEnumerable<CollectionInfo>

The list of collections.

ListCollectionsAsync(ListCollectionsOptions)

Get a list of all collections (name and metadata) in the current keyspace.

public Task<IEnumerable<CollectionInfo>> ListCollectionsAsync(ListCollectionsOptions options = null)

Parameters

options ListCollectionsOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<IEnumerable<CollectionInfo>>

The list of collections.

ListTableNames(ListTableNamesOptions)

public List<string> ListTableNames(ListTableNamesOptions options = null)

Parameters

options ListTableNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

List<string>

ListTableNamesAsync(ListTableNamesOptions)

List the tables in the database.

public Task<List<string>> ListTableNamesAsync(ListTableNamesOptions options = null)

Parameters

options ListTableNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<List<string>>

ListTables(ListTablesOptions)

Synchronous version of ListTablesAsync(ListTablesOptions)

public IEnumerable<TableInfo> ListTables(ListTablesOptions options = null)

Parameters

options ListTablesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

IEnumerable<TableInfo>

ListTablesAsync(ListTablesOptions)

List the tables in the database.

public Task<IEnumerable<TableInfo>> ListTablesAsync(ListTablesOptions options = null)

Parameters

options ListTablesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<IEnumerable<TableInfo>>

ListTypeNames(ListTypeNamesOptions)

public IEnumerable<string> ListTypeNames(ListTypeNamesOptions options = null)

Parameters

options ListTypeNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

IEnumerable<string>

ListTypeNamesAsync(ListTypeNamesOptions)

List User Defined Type names

public Task<IEnumerable<string>> ListTypeNamesAsync(ListTypeNamesOptions options = null)

Parameters

options ListTypeNamesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<IEnumerable<string>>

ListTypes(ListTypesOptions)

Synchronous version of ListTypesAsync(ListTypesOptions)

public List<UserDefinedTypeInfo> ListTypes(ListTypesOptions options = null)

Parameters

options ListTypesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

List<UserDefinedTypeInfo>

ListTypesAsync(ListTypesOptions)

List User Defined Types

public Task<List<UserDefinedTypeInfo>> ListTypesAsync(ListTypesOptions options = null)

Parameters

options ListTypesOptions

The options to use for the command, useful for overriding the keyspace, for example.

Returns

Task<List<UserDefinedTypeInfo>>

UseKeyspace(string)

Set the current keyspace to use for all subsequent operations (can be overridden in each method call by passing the adequate 'options' parameter).

public void UseKeyspace(string keyspace)

Parameters

keyspace string