다음을 통해 공유


Database Class

Definition

Represents a database in the Azure Cosmos DB account.

public class Database : Microsoft.Azure.Documents.Resource
type Database = class
    inherit Resource
Public Class Database
Inherits Resource
Inheritance

Examples

The example below creates a new Database with an Id property of 'MyDatabase'.

using (DocumentClient client = new DocumentClient(new Uri("service endpoint"), "auth key"))
{
    Database db = await client.CreateDatabaseAsync(new Database { Id = "MyDatabase" });
}

The example below creates a collection within this database with OfferThroughput set to 10000.

DocumentCollection coll = await client.CreateDocumentCollectionAsync(db.SelfLink,
    new DocumentCollection { Id = "MyCollection" }, 
    new RequestOptions { OfferThroughput = 10000} );

The example below queries for a Database by Id to retrieve the SelfLink.

using Microsoft.Azure.Documents.Linq;
Database database = client.CreateDatabaseQuery().Where(d => d.Id == "MyDatabase").AsEnumerable().FirstOrDefault();
string databaseLink = database.SelfLink;

The example below deletes the database using its SelfLink property.

await client.DeleteDatabaseAsync(db.SelfLink);

Remarks

Each Azure Cosmos DB database account can have zero or more databases. A database in Azure Cosmos DB is a logical container for document collections and users. Refer to for more details on databases.

Constructors

Database()

Initializes a new instance of the Database class for the Azure Cosmos DB service.

Properties

AltLink

Gets the alt-link associated with the resource from the Azure Cosmos DB service.

(Inherited from Resource)
CollectionsLink

Gets the self-link for collections from the Azure Cosmos DB service.

ETag

Gets the entity tag associated with the resource from the Azure Cosmos DB service.

(Inherited from Resource)
Id

Gets or sets the Id of the resource in the Azure Cosmos DB service.

(Inherited from Resource)
ResourceId

Gets or sets the Resource Id associated with the resource in the Azure Cosmos DB service.

(Inherited from Resource)
SelfLink

Gets the self-link associated with the resource from the Azure Cosmos DB service.

(Inherited from Resource)
Timestamp

Gets the last modified timestamp associated with the resource from the Azure Cosmos DB service.

(Inherited from Resource)
UsersLink

Gets the self-link for users from the Azure Cosmos DB service.

Methods

GetPropertyValue<T>(String)

Gets property value associated with the specified property name from the Azure Cosmos DB service.

(Inherited from Resource)
LoadFrom(JsonReader, JsonSerializerSettings)

Loads the object from the specified JSON reader in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
LoadFrom(JsonReader)

Loads the object from the specified JSON reader in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
SaveTo(Stream, SerializationFormattingPolicy, JsonSerializerSettings)

Saves the object to the specified stream in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
SaveTo(Stream, SerializationFormattingPolicy)

Saves the object to the specified stream in the Azure Cosmos DB service.

(Inherited from JsonSerializable)
SetPropertyValue(String, Object)

Sets property value associated with the specified property name in the Azure Cosmos DB service.

(Inherited from Resource)
ToByteArray()

Serialize to a byte array via SaveTo for the Azure Cosmos DB service.

(Inherited from Resource)
ToString()

Returns the string representation of the object in the Azure Cosmos DB service.

(Inherited from JsonSerializable)

Applies to

See also