Class Database
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
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
Methods
AlterType(string, IAlterTypeOperation, AlterTypeOptions)
Synchronous version of AlterTypeAsync(string, IAlterTypeOperation, AlterTypeOptions)
public void AlterType(string typeName, IAlterTypeOperation operation, AlterTypeOptions options = null)
Parameters
typeNamestringThe name of the User Defined Type to alter.
operationIAlterTypeOperationThe operation to apply to the User Defined Type.
optionsAlterTypeOptions
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
typeNamestringThe name of the User Defined Type to alter.
operationIAlterTypeOperationThe operation to apply to the User Defined Type.
optionsAlterTypeOptions
Returns
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
operationIAlterTypeOperationThe operation to apply to the User Defined Type.
optionsAlterTypeOptions
Returns
Type Parameters
TThe 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)
Synchronous version of AlterTypeAsync<T>(IAlterTypeOperation, AlterTypeOptions)
public void AlterType<T>(IAlterTypeOperation operation, AlterTypeOptions options = null) where T : new()
Parameters
operationIAlterTypeOperationThe operation to apply to the User Defined Type.
optionsAlterTypeOptions
Type Parameters
TThe 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)
Synchronous version of CreateCollectionAsync(string, CollectionDefinition, CreateCollectionOptions)
public Collection<Document> CreateCollection(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null)
Parameters
collectionNamestringThe name of the collection to create.
definitionCollectionDefinitionConfiguration for the collection.
optionsCreateCollectionOptionsOptions 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)
Synchronous version of CreateCollectionAsync(string, CreateCollectionOptions)
public Collection<Document> CreateCollection(string collectionName, CreateCollectionOptions options = null)
Parameters
collectionNamestringThe name of the collection to create.
optionsCreateCollectionOptionsOptions 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
collectionNamestringThe name of the collection to create.
definitionCollectionDefinitionConfiguration for the collection.
optionsCreateCollectionOptionsOptions 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
collectionNamestringThe name of the collection to create.
optionsCreateCollectionOptionsOptions 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
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T>>
A reference to the created collection.
Type Parameters
TThe 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
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T>>
A reference to the created collection.
Type Parameters
TThe 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
collectionNamestringThe name of the collection to create, overriding the information from the document type
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T>>
A reference to the created collection.
Type Parameters
TThe 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
collectionNamestringThe name of the collection to create, overriding the information from the document type
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T>>
A reference to the created collection.
Type Parameters
TThe 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
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T, TId>>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe 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
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T, TId>>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe 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
collectionNamestringThe name of the collection to create, overriding the information from the document type
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T, TId>>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe 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
collectionNamestringThe name of the collection to create, overriding the information from the document type
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Task<Collection<T, TId>>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe type to use for the document id.
CreateCollection<T>(CollectionDefinition, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T>(CollectionDefinition, CreateCollectionOptions)
public Collection<T> CreateCollection<T>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class
Parameters
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
CreateCollection<T>(CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T>(CreateCollectionOptions)
public Collection<T> CreateCollection<T>(CreateCollectionOptions options = null) where T : class
Parameters
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
CreateCollection<T>(string, CollectionDefinition, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T>(string, CollectionDefinition, CreateCollectionOptions)
public Collection<T> CreateCollection<T>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class
Parameters
collectionNamestringThe name of the collection to create, overriding the information from the document type
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
CreateCollection<T>(string, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T>(string, CreateCollectionOptions)
public Collection<T> CreateCollection<T>(string collectionName, CreateCollectionOptions options = null) where T : class
Parameters
collectionNamestringThe name of the collection to create, overriding the information from the document type
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
CreateCollection<T, TId>(CollectionDefinition, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T, TId>(CollectionDefinition, CreateCollectionOptions)
public Collection<T, TId> CreateCollection<T, TId>(CollectionDefinition definition, CreateCollectionOptions options = null) where T : class
Parameters
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T, TId>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe type to use for the document id.
CreateCollection<T, TId>(CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T, TId>(CreateCollectionOptions)
public Collection<T, TId> CreateCollection<T, TId>(CreateCollectionOptions options = null) where T : class
Parameters
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T, TId>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe type to use for the document id.
CreateCollection<T, TId>(string, CollectionDefinition, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T, TId>(string, CollectionDefinition, CreateCollectionOptions)
public Collection<T, TId> CreateCollection<T, TId>(string collectionName, CollectionDefinition definition, CreateCollectionOptions options = null) where T : class
Parameters
collectionNamestringThe name of the collection to create, overriding the information from the document type
definitionCollectionDefinitionConfiguration for the collection, overriding the information from the document type.
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T, TId>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe type to use for the document id.
CreateCollection<T, TId>(string, CreateCollectionOptions)
Synchronous version of CreateCollectionAsync<T, TId>(string, CreateCollectionOptions)
public Collection<T, TId> CreateCollection<T, TId>(string collectionName, CreateCollectionOptions options = null) where T : class
Parameters
collectionNamestringThe name of the collection to create, overriding the information from the document type
optionsCreateCollectionOptionsOptions for the collection, such as API keys, keyspace override, or timeouts.
Returns
- Collection<T, TId>
A reference to the created collection.
Type Parameters
TThe type to use for the document.
TIdThe type to use for the document id.
CreateTable(string, TableDefinition, CreateTableOptions)
Synchronous version of CreateTableAsync(string, TableDefinition, CreateTableOptions)
public Table<Row> CreateTable(string tableName, TableDefinition definition, CreateTableOptions options = null)
Parameters
tableNamestringThe name to give the table.
definitionTableDefinitionThe table definition describing columns and primary key.
optionsCreateTableOptionsOptions for the create table command.
Returns
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
tableNamestringThe name to give the table.
definitionTableDefinitionThe table definition describing columns and primary key.
optionsCreateTableOptionsOptions for the create table command.
Returns
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
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe 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
definitionTableDefinitionA table definition, replacing that inferred from TRow.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe 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
tableNamestringThe name to give the table.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe 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
tableNamestringThe name to give the table.
definitionTableDefinitionA table definition, replacing that inferred from TRow.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe type representing the table row schema.
CreateTable<TRow>(CreateTableOptions)
Synchronous version of CreateTableAsync<TRow>(CreateTableOptions)
public Table<TRow> CreateTable<TRow>(CreateTableOptions options = null) where TRow : class, new()
Parameters
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe type representing the table row schema.
CreateTable<TRow>(TableDefinition, CreateTableOptions)
Synchronous version of CreateTableAsync<TRow>(TableDefinition, CreateTableOptions)
public Table<TRow> CreateTable<TRow>(TableDefinition definition, CreateTableOptions options = null) where TRow : class, new()
Parameters
definitionTableDefinitionA table definition, replacing that inferred from TRow.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe type representing the table row schema.
CreateTable<TRow>(string, CreateTableOptions)
Synchronous version of CreateTableAsync<TRow>(string, CreateTableOptions)
public Table<TRow> CreateTable<TRow>(string tableName, CreateTableOptions options = null) where TRow : class, new()
Parameters
tableNamestringThe name to give the table.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe type representing the table row schema.
CreateTable<TRow>(string, TableDefinition, CreateTableOptions)
Synchronous version of CreateTableAsync<TRow>(string, TableDefinition, CreateTableOptions)
public Table<TRow> CreateTable<TRow>(string tableName, TableDefinition definition, CreateTableOptions options = null) where TRow : class
Parameters
tableNamestringThe name to give the table.
definitionTableDefinitionA table definition, replacing that inferred from TRow.
optionsCreateTableOptionsOptions for the create table command.
Returns
Type Parameters
TRowThe type representing the table row schema.
CreateType(string, UserDefinedTypeDefinition, CreateTypeOptions)
Synchronous version of CreateTypeAsync(string, UserDefinedTypeDefinition, CreateTypeOptions)
public void CreateType(string typeName, UserDefinedTypeDefinition definition, CreateTypeOptions options = null)
Parameters
typeNamestringThe name of the type to create
definitionUserDefinedTypeDefinitionThe type definition
optionsCreateTypeOptions
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
typeNamestringThe name of the type to create
definitionUserDefinedTypeDefinitionThe type definition
optionsCreateTypeOptions
Returns
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
optionsCreateTypeOptions
Returns
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
typeNamestringThe name of the type to create (overrides the name extracted from the provided class)
optionsCreateTypeOptions
Returns
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)
Synchronous version of CreateTypeAsync<T>(CreateTypeOptions)
public void CreateType<T>(CreateTypeOptions options = null)
Parameters
optionsCreateTypeOptions
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)
Synchronous version of CreateTypeAsync<T>(CreateTypeOptions)
public void CreateType<T>(string typeName, CreateTypeOptions options = null)
Parameters
typeNamestringoptionsCreateTypeOptions
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)
Synchronous version of DoesCollectionExistAsync(string, DoesCollectionExistOptions).
public bool DoesCollectionExist(string collectionName, DoesCollectionExistOptions options = null)
Parameters
collectionNamestringoptionsDoesCollectionExistOptionsThe 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
collectionNamestringoptionsDoesCollectionExistOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
DoesTableExist(string, DoesTableExistOptions)
Synchronous version of DoesTableExistAsync(string, DoesTableExistOptions).
public bool DoesTableExist(string tableName, DoesTableExistOptions options = null)
Parameters
tableNamestringoptionsDoesTableExistOptionsThe 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
tableNamestringoptionsDoesTableExistOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
DropCollection(string, DropCollectionOptions)
Synchronous version of DropCollectionAsync(string, DropCollectionOptions)
public void DropCollection(string collectionName, DropCollectionOptions options = null)
Parameters
collectionNamestringoptionsDropCollectionOptions
DropCollectionAsync(string, DropCollectionOptions)
Remove a collection from the database.
public Task DropCollectionAsync(string collectionName, DropCollectionOptions options = null)
Parameters
collectionNamestringThe collection to remove
optionsDropCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
DropCollectionAsync<T>(DropCollectionOptions)
Remove a collection from the database based on the class for its documents.
public Task DropCollectionAsync<T>(DropCollectionOptions options = null)
Parameters
optionsDropCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
Type Parameters
TThe type of the document stored in the referenced collection. The name of the collection to drop is extracted from this.
DropCollection<T>(DropCollectionOptions)
Synchronous version of DropCollectionAsync<T>(DropCollectionOptions)
public void DropCollection<T>(DropCollectionOptions options = null)
Parameters
optionsDropCollectionOptions
Type Parameters
TThe type of the document stored in the referenced collection
DropTable(string, DropTableOptions)
Synchronous version of DropTableAsync(string, DropTableOptions)
public void DropTable(string tableName, DropTableOptions options = null)
Parameters
tableNamestringoptionsDropTableOptionsThe 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
tableNamestringoptionsDropTableOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
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
optionsDropTableOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
Type Parameters
TRow
DropTableIndex(string, DropTableIndexOptions)
Synchronous version of DropTableIndexAsync(string, DropTableIndexOptions)
public void DropTableIndex(string indexName, DropTableIndexOptions options = null)
Parameters
indexNamestringoptionsDropTableIndexOptionsThe 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
indexNamestringoptionsDropTableIndexOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
DropTable<TRow>(DropTableOptions)
Synchronous version of DropTableAsync<TRow>(DropTableOptions)
public void DropTable<TRow>(DropTableOptions options = null) where TRow : class, new()
Parameters
optionsDropTableOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Type Parameters
TRow
DropType(string, DropTypeOptions)
Synchronous version of DropTypeAsync(string, DropTypeOptions)
public void DropType(string typeName, DropTypeOptions options = null)
Parameters
typeNamestringThe name of the user-defined type to drop.
optionsDropTypeOptions
DropTypeAsync(string, DropTypeOptions)
Drop a User Defined Type dynamically by specifying the type name
public Task DropTypeAsync(string typeName, DropTypeOptions options = null)
Parameters
typeNamestringThe name of the user-defined type to drop.
optionsDropTypeOptions
Returns
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
optionsDropTypeOptions
Returns
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
optionsDropTypeOptions
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
optionsGetAdminOptionsOptional. 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
optionsGetAdminOptionsOptional. The options for the admin, useful e.g. for customizing timeout settings
Returns
- TAdmin
An instance of the specified admin type
Type Parameters
TAdminThe 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
collectionNamestringoptionsGetCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
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
optionsGetCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
- Collection<T>
Type Parameters
TThe 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
collectionNamestringoptionsGetCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
- Collection<T>
Type Parameters
TThe 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
optionsGetCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
- Collection<T, TId>
Type Parameters
TThe type of the document stored in the referenced collection
TIdThe 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
collectionNamestringoptionsGetCollectionOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
- Collection<T, TId>
Type Parameters
TTId
GetTable(string, GetTableOptions)
Returns a reference to a table by name.
public Table<Row> GetTable(string tableName, GetTableOptions options = null)
Parameters
tableNamestringThe name of the table being targeted.
optionsGetTableOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
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
optionsGetTableOptionsThe 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
TRowThe 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
tableNamestringThe name of the table - if provided, overrides the information found on the row type.
optionsGetTableOptionsThe 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
TRowThe type of the rows in the table.
ListCollectionNames(ListCollectionNamesOptions)
Synchronous version of ListCollectionNamesAsync(ListCollectionNamesOptions).
public List<string> ListCollectionNames(ListCollectionNamesOptions options = null)
Parameters
optionsListCollectionNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListCollectionNamesAsync(ListCollectionNamesOptions)
Get a list of all collection names in the current keyspace.
public Task<List<string>> ListCollectionNamesAsync(ListCollectionNamesOptions options = null)
Parameters
optionsListCollectionNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListCollections(ListCollectionsOptions)
Synchronous version of ListCollectionsAsync(ListCollectionsOptions).
public IEnumerable<CollectionInfo> ListCollections(ListCollectionsOptions options = null)
Parameters
optionsListCollectionsOptionsThe 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
optionsListCollectionsOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
- Task<IEnumerable<CollectionInfo>>
The list of collections.
ListTableNames(ListTableNamesOptions)
Synchronous version of ListTableNamesAsync(ListTableNamesOptions)
public List<string> ListTableNames(ListTableNamesOptions options = null)
Parameters
optionsListTableNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTableNamesAsync(ListTableNamesOptions)
List the tables in the database.
public Task<List<string>> ListTableNamesAsync(ListTableNamesOptions options = null)
Parameters
optionsListTableNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTables(ListTablesOptions)
Synchronous version of ListTablesAsync(ListTablesOptions)
public IEnumerable<TableInfo> ListTables(ListTablesOptions options = null)
Parameters
optionsListTablesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTablesAsync(ListTablesOptions)
List the tables in the database.
public Task<IEnumerable<TableInfo>> ListTablesAsync(ListTablesOptions options = null)
Parameters
optionsListTablesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTypeNames(ListTypeNamesOptions)
Synchronous version of ListTypeNamesAsync(ListTypeNamesOptions)
public IEnumerable<string> ListTypeNames(ListTypeNamesOptions options = null)
Parameters
optionsListTypeNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTypeNamesAsync(ListTypeNamesOptions)
List User Defined Type names
public Task<IEnumerable<string>> ListTypeNamesAsync(ListTypeNamesOptions options = null)
Parameters
optionsListTypeNamesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTypes(ListTypesOptions)
Synchronous version of ListTypesAsync(ListTypesOptions)
public List<UserDefinedTypeInfo> ListTypes(ListTypesOptions options = null)
Parameters
optionsListTypesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
ListTypesAsync(ListTypesOptions)
List User Defined Types
public Task<List<UserDefinedTypeInfo>> ListTypesAsync(ListTypesOptions options = null)
Parameters
optionsListTypesOptionsThe options to use for the command, useful for overriding the keyspace, for example.
Returns
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
keyspacestring