当前位置: 首页>>代码示例>>C#>>正文


C# DocumentClient.DeleteDatabaseAsync方法代码示例

本文整理汇总了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();
        }
开发者ID:ritasker,项目名称:TechTest,代码行数:10,代码来源:DocumentDbInitialiserSpecs.cs

示例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();
        }
开发者ID:stamo,项目名称:SoftUniConfChepelare2015,代码行数:23,代码来源:FamilyRegistry.cs

示例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);
            }
        }
开发者ID:softwarejc,项目名称:documentdb-backups-csharp,代码行数:14,代码来源:DatabaseService.cs

示例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();
        }
开发者ID:kinpro,项目名称:documentdb-dotnet-getting-started,代码行数:101,代码来源:Program.cs

示例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();
        }
开发者ID:crypteron,项目名称:documentdb-dotnet-getting-started-secure,代码行数:101,代码来源:Program.cs

示例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();
        }
开发者ID:attila-kiss,项目名称:azure-documentdb-net,代码行数:101,代码来源:Program.cs

示例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


注:本文中的Microsoft.Azure.Documents.Client.DocumentClient.DeleteDatabaseAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。