本文整理汇总了C#中Microsoft.Azure.Documents.Client.DocumentClient.DeleteDatabaseAsync方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentClient.DeleteDatabaseAsync方法的具体用法?C# DocumentClient.DeleteDatabaseAsync怎么用?C# DocumentClient.DeleteDatabaseAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Documents.Client.DocumentClient
的用法示例。
在下文中一共展示了DocumentClient.DeleteDatabaseAsync方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispose
public void Dispose()
{
var configuration = (Configuration)ConfigurationManager.GetSection("DocumentDbProvider");
using (var client = new DocumentClient(new Uri(configuration.Endpoint), configuration.Key))
{
client.DeleteDatabaseAsync(_documentDbContext.Database.SelfLink).Wait();
}
_documentDbContext.Dispose();
}
示例2: GetStartedDemo
private static async Task GetStartedDemo()
{
// Create a new instance of the DocumentClient
client = new DocumentClient(new Uri(EndpointUrl), AuthorizationKey);
database = await CreateDatabaseAsync();
await CreateCollectionAsync();
await SeedDocuments();
await SampleSqlQuery();
await SampleLinqQuery();
await SampleLambdaQuery();
Console.WriteLine("Press any key to delete database...");
Console.ReadKey();
await client.DeleteDatabaseAsync("dbs/" + database.Id);
client.Dispose();
}
示例3: DeleteDatabase
/// <summary>
/// Deletes the service database.
/// </summary>
public static async Task DeleteDatabase(DocumentClient client, string databaseId)
{
// Get the database
var db = client.CreateDatabaseQuery().Where(d => d.Id == databaseId).AsEnumerable().FirstOrDefault();
// Return the database or create it if not exists yet
if (db != null)
{
await client.DeleteDatabaseAsync(db.SelfLink);
}
}
示例4: GetStartedDemo
//.........这里部分代码省略.........
new Parent { FirstName = "Mary Kay"}
},
Children = new Child[] {
new Child
{
FirstName = "Henriette Thaulow",
Gender = "female",
Grade = 5,
Pets = new Pet[] {
new Pet { GivenName = "Fluffy" }
}
}
},
Address = new Address { State = "WA", County = "King", City = "Seattle" },
IsRegistered = true
};
// id based routing for the first argument, "dbs/FamilyRegistry/colls/FamilyCollection"
await client.CreateDocumentAsync("dbs/" + database.Id + "/colls/" + documentCollection.Id, andersonFamily);
WriteMessage("Created dbs/FamilyRegistry/colls/FamilyCollection/docs/AndersenFamily");
}
// Check to verify a document with the id=AndersenFamily does not exist
document = client.CreateDocumentQuery("dbs/" + database.Id + "/colls/" + documentCollection.Id).Where(d => d.Id == "WakefieldFamily").AsEnumerable().FirstOrDefault();
if (document == null)
{
// Create the WakeField document
Family wakefieldFamily = new Family
{
Id = "WakefieldFamily",
Parents = new Parent[] {
new Parent { FamilyName= "Wakefield", FirstName= "Robin" },
new Parent { FamilyName= "Miller", FirstName= "Ben" }
},
Children = new Child[] {
new Child {
FamilyName= "Merriam",
FirstName= "Jesse",
Gender= "female",
Grade= 8,
Pets= new Pet[] {
new Pet { GivenName= "Goofy" },
new Pet { GivenName= "Shadow" }
}
},
new Child {
FamilyName= "Miller",
FirstName= "Lisa",
Gender= "female",
Grade= 1
}
},
Address = new Address { State = "NY", County = "Manhattan", City = "NY" },
IsRegistered = false
};
// id based routing for the first argument, "dbs/FamilyRegistry/colls/FamilyCollection"
await client.CreateDocumentAsync("dbs/" + database.Id + "/colls/" + documentCollection.Id, wakefieldFamily);
WriteMessage("Created dbs/FamilyRegistry/colls/FamilyCollection/docs/WakefieldFamily");
}
// Query the documents using DocumentDB SQL for the Andersen family
var families = client.CreateDocumentQuery("dbs/" + database.Id + "/colls/" + documentCollection.Id,
"SELECT * " +
"FROM Families f " +
"WHERE f.id = \"AndersenFamily\"");
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from SQL", family);
}
// Query the documents using LINQ for the Andersen family
families =
from f in client.CreateDocumentQuery("dbs/" + database.Id + "/colls/" + documentCollection.Id)
where f.Id == "AndersenFamily"
select f;
foreach (var family in families)
{
Console.WriteLine("Read {0} from LINQ", family);
}
// Query the documents using LINQ lambdas for the Andersen family
families = client.CreateDocumentQuery("dbs/" + database.Id + "/colls/" + documentCollection.Id)
.Where(f => f.Id == "AndersenFamily")
.Select(f => f);
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from LINQ query", family);
}
// Clean up/delete the database and client
await client.DeleteDatabaseAsync("dbs/" + database.Id);
client.Dispose();
}
示例5: GetStartedDemo
//.........这里部分代码省略.........
Address = new Address { State = "WA", County = "King", City = "Seattle" },
IsRegistered = true,
GeneticCondition = "diabetes"
};
Crypteron.CipherObject.Seal(andersonFamily); // or andersonFamily.Seal()
// id based routing for the first argument, "dbs/FamilyRegistry/colls/FamilyCollection"
await client.CreateDocumentAsync("dbs/" + database.Id + "/colls/" + documentCollection.Id, andersonFamily);
WriteMessage("Created dbs/FamilyRegistry/colls/FamilyCollection/docs/AndersenFamily");
}
// Check to verify a document with the id=AndersenFamily does not exist
document = client.CreateDocumentQuery("dbs/" + database.Id + "/colls/" + documentCollection.Id).Where(d => d.Id == "WakefieldFamily").AsEnumerable().FirstOrDefault();
if (document == null)
{
// Create the WakeField document
Family wakefieldFamily = new Family
{
Id = "WakefieldFamily",
Parents = new Parent[] {
new Parent { FamilyName= "Wakefield", FirstName= "Robin" },
new Parent { FamilyName= "Miller", FirstName= "Ben" }
},
Children = new Child[] {
new Child {
FamilyName= "Merriam",
FirstName= "Jesse",
Gender= "female",
Grade= 8,
Pets= new Pet[] {
new Pet { GivenName= "Goofy" },
new Pet { GivenName= "Shadow" }
}
},
new Child {
FamilyName= "Miller",
FirstName= "Lisa",
Gender= "female",
Grade= 1
}
},
Address = new Address { State = "NY", County = "Manhattan", City = "NY" },
IsRegistered = false,
};
Crypteron.CipherObject.Seal(wakefieldFamily); // or wakefieldFamily.Seal()
// id based routing for the first argument, "dbs/FamilyRegistry/colls/FamilyCollection"
await client.CreateDocumentAsync("dbs/" + database.Id + "/colls/" + documentCollection.Id, wakefieldFamily);
WriteMessage("Created dbs/FamilyRegistry/colls/FamilyCollection/docs/WakefieldFamily");
}
// Query the documents using DocumentDB SQL for the Andersen family
var families = client.CreateDocumentQuery<Family>("dbs/" + database.Id + "/colls/" + documentCollection.Id,
"SELECT * " +
"FROM Families f " +
"WHERE f.id = \"AndersenFamily\"");
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from SQL", JsonConvert.SerializeObject(family.Unseal(), Formatting.Indented));
}
// Query the documents using LINQ for the Andersen family
families =
from f in client.CreateDocumentQuery<Family>("dbs/" + database.Id + "/colls/" + documentCollection.Id)
where f.Id == "AndersenFamily"
select f;
foreach (var family in families)
{
Console.WriteLine("Read {0} from LINQ", JsonConvert.SerializeObject(family.Unseal(), Formatting.Indented));
}
// Query the documents using LINQ lambdas for the Andersen family
// Need to get results back in original class with Secure attributes
// Dynamic JObject is not currently supported
families = client.CreateDocumentQuery<Family>("dbs/" + database.Id + "/colls/" + documentCollection.Id)
.Where(f => f.Id == "AndersenFamily")
.Select(f => f);
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from LINQ query", JsonConvert.SerializeObject(family.Unseal(), Formatting.Indented));
}
// Clean up/delete the database and client
Console.WriteLine("Done. Press 'd' to delete database prior to exiting");
var choice = Console.ReadKey().KeyChar;
if (choice == 'd' || choice == 'D')
{
Console.WriteLine("\nDeleting database ...");
await client.DeleteDatabaseAsync("dbs/" + database.Id);
}
client.Dispose();
}
示例6: GetStartedDemo
//.........这里部分代码省略.........
document = client.CreateDocumentQuery(documentCollection.DocumentsLink).Where(d => d.Id == "WakefieldFamily").AsEnumerable().FirstOrDefault();
if (document == null)
{
// Create the WakeField document
Family WakefieldFamily = new Family
{
Id = "WakefieldFamily",
Parents = new Parent[] {
new Parent { FamilyName= "Wakefield", FirstName= "Robin" },
new Parent { FamilyName= "Miller", FirstName= "Ben" }
},
Children = new Child[] {
new Child {
FamilyName= "Merriam",
FirstName= "Jesse",
Gender= "female",
Grade= 8,
Pets= new Pet[] {
new Pet { GivenName= "Goofy" },
new Pet { GivenName= "Shadow" }
}
},
new Child {
FamilyName= "Miller",
FirstName= "Lisa",
Gender= "female",
Grade= 1
}
},
Address = new Address { State = "NY", County = "Manhattan", City = "NY" },
IsRegistered = false
};
await client.CreateDocumentAsync(documentCollection.DocumentsLink, WakefieldFamily);
}
else { Warn("document"); }
// Query the documents using DocumentDB SQL for the Andersen family
var families = client.CreateDocumentQuery(documentCollection.DocumentsLink,
"SELECT * " +
"FROM Families f " +
"WHERE f.id = \"AndersenFamily\"");
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from SQL", family);
}
// Query the documents using LINQ for the Andersen family
families =
from f in client.CreateDocumentQuery(documentCollection.DocumentsLink)
where f.Id == "AndersenFamily"
select f;
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from LINQ", family);
}
// Query the documents using LINQ lambdas for the Andersen family
families = client.CreateDocumentQuery(documentCollection.DocumentsLink)
.Where(f => f.Id == "AndersenFamily")
.Select(f => f);
foreach (var family in families)
{
Console.WriteLine("\tRead {0} from LINQ query", family);
}
// Query the documents using DocumentSQl with one join
var items = client.CreateDocumentQuery<dynamic>(documentCollection.DocumentsLink,
"SELECT f.id, c.FirstName AS child " +
"FROM Families f " +
"JOIN c IN f.Children");
foreach (var item in items.ToList())
{
Console.WriteLine(item);
}
// Query the documents using LINQ with one join
items = client.CreateDocumentQuery<Family>(documentCollection.DocumentsLink)
.SelectMany(family => family.Children
.Select(children => new
{
family = family.Id,
child = children.FirstName
}));
foreach (var item in items.ToList())
{
Console.WriteLine(item);
}
// Clean up/delete the database and client
await client.DeleteDatabaseAsync(database.SelfLink);
client.Dispose();
}
示例7: OneTimeTearDown
public async Task OneTimeTearDown()
{
var client = new DocumentClient(new Uri(document_db_connection_address), document_db_connection_key);
await client.DeleteDatabaseAsync($"dbs/{database_id}");
}
开发者ID:JaimieAvery,项目名称:Azure.ServiceFabric.ReliableActors.EventSourcing,代码行数:5,代码来源:EventStoreTests.cs