Consultar una base de datos Azure Cosmos DB
1 2 |
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
1 2 3 4 5 6 7 8 |
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
1 2 3 4 5 |
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
1 2 3 4 5 6 7 8 9 |
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); } |