本文整理汇总了C#中Microsoft.Azure.Documents.Client.DocumentClient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentClient.Dispose方法的具体用法?C# DocumentClient.Dispose怎么用?C# DocumentClient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Documents.Client.DocumentClient
的用法示例。
在下文中一共展示了DocumentClient.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: CreateDatabase
//.........这里部分代码省略.........
new MenuItem { Id = "4", ItemName = "Freedom Sized Chicken Dinner", Calories = 4444, Price = 44M },
new MenuItem { Id = "5", ItemName = "Small Chicken Wings", Calories = 500, Price = 5M },
new MenuItem { Id = "6", ItemName = "Medium Chicken Wings", Calories = 1000, Price = 7M },
new MenuItem { Id = "7", ItemName = "Large Chicken Wings", Calories = 1500, Price = 10M }
},
Address = new Address
{
Id = "3",
StreetNumber = "500 Midtown Ave",
City = "Los Angeles",
State = "California",
ZipCode = "90210"
}
};
await client.CreateDocumentAsync(col.DocumentsLink, doc3);
}
doc = client.CreateDocumentQuery(col.DocumentsLink)
.Where(d => d.Id == "4").AsEnumerable().FirstOrDefault();
if (doc == null)
{
Restaurant doc4 = new Restaurant
{
Id = "4",
RName = "Four Stars",
UserId = "user2",
FName = "Ash",
LName = "Awesome",
MenuItems = new MenuItem[] {
new MenuItem { Id = "1", ItemName = "Pretentious Meal #1", Calories = 1, Price = 100M },
new MenuItem { Id = "2", ItemName = "Pretentious Meal #2", Calories = 2, Price = 100M },
new MenuItem { Id = "3", ItemName = "Pretentious Meal #3", Calories = 3, Price = 300M },
new MenuItem { Id = "4", ItemName = "Small Gerbil Food", Calories = 4, Price = 400M },
new MenuItem { Id = "5", ItemName = "Medium Gerbil Food", Calories = 5, Price = 50M },
new MenuItem { Id = "6", ItemName = "Large Gerbil Food", Calories = 6, Price = 60M }
},
Address = new Address
{
Id = "4",
StreetNumber = "3001 SE Belmont St.",
City = "Portland",
State = "Oregon",
ZipCode = "97214"
}
};
await client.CreateDocumentAsync(col.DocumentsLink, doc4);
}
var items = client.CreateDocumentQuery(col.DocumentsLink, "SELECT r.id, r.rName FROM Restaurant r");
// Query and check what I have entered is there.
foreach(var rest in items)
{
Console.WriteLine(rest);
}
// Begin seeding of the collection with users
Document user = client.CreateDocumentQuery(col.DocumentsLink).Where(d => d.Id == "user1")
.AsEnumerable().FirstOrDefault();
if (user == null)
{
Users user1 = new Users
{
Id = "user1",
UserName = "King Phil",
Password = "BestEver"
};
await client.CreateDocumentAsync(col.DocumentsLink, user1);
}
user = client.CreateDocumentQuery(col.DocumentsLink).Where(d => d.Id == "user2")
.AsEnumerable().FirstOrDefault();
if (user == null)
{
Users user2 = new Users
{
Id = "user2",
UserName = "Nobody",
Password = "noOneCares"
};
await client.CreateDocumentAsync(col.DocumentsLink, user2);
}
// TODO: Try to query a user assosciated with a restaurant as a separate document.
/*
*/
//await client.DeleteDatabaseAsync(database.SelfLink);
// Dispose of the client connection.
client.Dispose();
}
示例4: 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();
}
示例5: 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();
}