Share via


CosmosClient.GetDatabase(String) Methode

Definition

Gibt einen Proxyverweis auf eine Datenbank zurück.

public virtual Microsoft.Azure.Cosmos.Database GetDatabase (string id);
abstract member GetDatabase : string -> Microsoft.Azure.Cosmos.Database
override this.GetDatabase : string -> Microsoft.Azure.Cosmos.Database
Public Overridable Function GetDatabase (id As String) As Database

Parameter

id
String

Die Cosmos-Datenbank-ID

Gibt zurück

Cosmos-Datenbankproxy

Beispiele

Database db = cosmosClient.GetDatabase("myDatabaseId");
DatabaseResponse response = await db.ReadAsync();

Hinweise

Database Der Proxyverweis garantiert nicht die Existenz. Stellen Sie sicher, dass die Datenbank über CreateDatabaseAsync(String, Nullable<Int32>, RequestOptions, CancellationToken) oder CreateDatabaseIfNotExistsAsync(String, Nullable<Int32>, RequestOptions, CancellationToken)vorhanden ist, bevor Sie darauf arbeiten.

Gilt für: