Snippets | Azure Cosmos DB

Consultar una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

Crear una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

if (database==null)
{
     database = await client.CreateDatabaseAsync(new Database { Id = databaseId });
     Console.WriteLine("\n2. Created Database: id - {0} and selfLink - {1}", database.Id, database.SelfLink);
}

Leer una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

database = await client.ReadDatabaseAsync(UriFactory.CreateDatabaseUri(databaseId));
Console.WriteLine("\n3. Read a database resource: {0}", database);

Leer un conjunto de bases de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

var databases = await client.ReadDatabaseFeedAsync();
Console.WriteLine("\n4. Reading all databases resources for an account");
foreach (var db in databases)
{
     Console.WriteLine(db);    
}

 

Snippets | Azure Cosmos DB

Consultar una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

Crear una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

if (database==null)
{
     database = await client.CreateDatabaseAsync(new Database { Id = databaseId });
     Console.WriteLine("\n2. Created Database: id - {0} and selfLink - {1}", database.Id, database.SelfLink);
}

Leer una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

database = await client.ReadDatabaseAsync(UriFactory.CreateDatabaseUri(databaseId));
Console.WriteLine("\n3. Read a database resource: {0}", database);

Leer un conjunto de bases de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

var databases = await client.ReadDatabaseFeedAsync();
Console.WriteLine("\n4. Reading all databases resources for an account");
foreach (var db in databases)
{
     Console.WriteLine(db);    
}

 

Snippets | Azure Cosmos DB

Consultar una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

Crear una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

if (database==null)
{
     database = await client.CreateDatabaseAsync(new Database { Id = databaseId });
     Console.WriteLine("\n2. Created Database: id - {0} and selfLink - {1}", database.Id, database.SelfLink);
}

Leer una base de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

database = await client.ReadDatabaseAsync(UriFactory.CreateDatabaseUri(databaseId));
Console.WriteLine("\n3. Read a database resource: {0}", database);

Leer un conjunto de bases de datos Azure Cosmos DB

Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).AsEnumerable().FirstOrDefault();
Console.WriteLine("1. Query for a database returned: {0}", database==null?"no results":database.Id);

var databases = await client.ReadDatabaseFeedAsync();
Console.WriteLine("\n4. Reading all databases resources for an account");
foreach (var db in databases)
{
     Console.WriteLine(db);    
}

 

También te podría gustar...