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


C# DocumentClient.CreateDocumentCollectionQuery方法代码示例

本文整理汇总了C#中Microsoft.Azure.Documents.Client.DocumentClient.CreateDocumentCollectionQuery方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentClient.CreateDocumentCollectionQuery方法的具体用法?C# DocumentClient.CreateDocumentCollectionQuery怎么用?C# DocumentClient.CreateDocumentCollectionQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Azure.Documents.Client.DocumentClient的用法示例。


在下文中一共展示了DocumentClient.CreateDocumentCollectionQuery方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UpdateDcAll

        public static async Task UpdateDcAll(string endpointUrl, string authorizationKey)
        {
            DocumentClient client = new DocumentClient(new Uri(endpointUrl), authorizationKey);
            var database = await DocumentDB.GetDB(client);

            IEnumerable<DocumentCollection> dz = client.CreateDocumentCollectionQuery(database.SelfLink)
                .AsEnumerable();


            DocumentCollection origin = client.CreateDocumentCollectionQuery(database.SelfLink)
                .Where(c => c.Id == "LMSCollection")
                .AsEnumerable()
                .FirstOrDefault();

            //search collection
            var ds =
                from d in client.CreateDocumentQuery<DcAllocate>(origin.DocumentsLink)
                where d.Type == "DisList"
                select d;
            foreach (var d in ds)
            {
                if (d.District.Contains("tst-azhang14"))
                {
                    Console.WriteLine(d.DcName);
                }
            }

            /* foreach (var x in dz)
            {
                Console.WriteLine(x.Id + x.DocumentsLink);
                await UpdateDc(x, client, database, origin);
            }*/
        }
开发者ID:tzkwizard,项目名称:ELS,代码行数:33,代码来源:Dichotomy.cs

示例2: GetDocumentCollection

 private static DocumentCollection GetDocumentCollection(DocumentClient client, Database database, string collectionId)
 {
     return client.CreateDocumentCollectionQuery(database.SelfLink)
         .Where(c => c.Id == collectionId)
         .AsEnumerable()
         .SingleOrDefault();
 }
开发者ID:paulhoulston,项目名称:IssueTracker,代码行数:7,代码来源:DocumentDbCollection.cs

示例3: GetDocumentDbClient

        private async Task<DocumentClient> GetDocumentDbClient()
        {
            var client = new DocumentClient(new Uri(_endPointUrl), _authorizationKKry);

            var database = client.CreateDatabaseQuery().
                Where(db => db.Id == DocumentDbId).AsEnumerable().FirstOrDefault();

            if (database == null)
            {
                database = await client.CreateDatabaseAsync(
                    new Database
                    {
                        Id = DocumentDbId
                    });    
            }

            DocumentCollection = client.CreateDocumentCollectionQuery
                ("dbs/" + database.Id).Where(c => c.Id == _collectionId).AsEnumerable().FirstOrDefault();

            if (DocumentCollection == null)
            {
                DocumentCollection = await client.CreateDocumentCollectionAsync("dbs/" + DocumentDbId,
                new DocumentCollection
                {
                    Id = _collectionId
                });

            }
           

            return client;
        }
开发者ID:sogeti,项目名称:Site-provisioning,代码行数:32,代码来源:SiteTemplateRepository.cs

示例4: GetStart

        //new add
        private static async Task GetStart()
        {
            var client = new DocumentClient(new Uri(EndpointURL), AuthorizationKey);
            
            database = client.CreateDatabaseQuery().Where(d => d.Id == "ppweict").AsEnumerable().FirstOrDefault();
            collection = client.CreateDocumentCollectionQuery(database.SelfLink).Where(c => c.Id == "Exam_Pool").AsEnumerable().FirstOrDefault();


            var EfDs = client.CreateDocumentQuery(collection.DocumentsLink, "SELECT * FROM Exam_pool f WHERE f.verify = \"true\" ");
            foreach (exam_pool EfD in EfDs)
            {
                Console.WriteLine(EfD);
                exams.Add(new exam_pool
                {
                    id = EfD.id,
                    exam_catrgory = EfD.exam_catrgory,
                    exam_level = EfD.exam_level,
                    questions = EfD.questions,
                    answer_A = EfD.answer_A,
                    answer_B = EfD.answer_B,
                    answer_C = EfD.answer_C,
                    answer_D = EfD.answer_D,
                    answer_E = EfD.answer_E,
                    C_answer = EfD.C_answer,
                    exam_link = EfD.exam_link,
                    lang = EfD.lang,
                    verify = EfD.verify,
                });
            }
        }
开发者ID:Steven-Tsai,项目名称:ppweict_Web_API,代码行数:31,代码来源:exam_pool_1_Repository.cs

示例5: FindDocumentCollection

 static DocumentCollection FindDocumentCollection(DocumentClient client, Database database, string name)
 {
     return client.CreateDocumentCollectionQuery(database.SelfLink)
         .Where(x => x.Id == name)
         .ToList()
         .SingleOrDefault();
 }
开发者ID:korz,项目名称:IntroductionToDocumentDB,代码行数:7,代码来源:Program.cs

示例6: DocumentDBDataReader

        public DocumentDBDataReader()
        {
            var dict = new Dictionary<HighchartsHelper.DocumentTypes, IEnumerable<Document>>();
            _documentClient = new DocumentClient(new Uri(ConfigurationManager.AppSettings["DocumentServiceEndpoint"]), ConfigurationManager.AppSettings["DocumentKey"]);

            _database = _documentClient.CreateDatabaseQuery().Where(db => db.Id == ConfigurationManager.AppSettings["DocumentDatabase"]).AsEnumerable().FirstOrDefault();

            if (_database == null)
                throw new ApplicationException("Error: DocumentDB database does not exist");

            // Check to verify a document collection with the id=FamilyCollection does not exist
            _documentCollection = _documentClient.CreateDocumentCollectionQuery(_database.CollectionsLink).Where(c => c.Id == ConfigurationManager.AppSettings["DocumentCollection"]).AsEnumerable().FirstOrDefault();

            if (_documentCollection == null)
                throw new ApplicationException("Error: DocumentDB collection does not exist");


            try
            {
                _documentClient.CreateUserDefinedFunctionAsync(_documentCollection.SelfLink, new UserDefinedFunction
                {
                    Id = "ISDEFINED",
                    Body = @"function ISDEFINED(doc, prop) {
                            return doc[prop] !== undefined;
                        }"
                });  
            }
            catch (Exception)
            {
                //fail silently for now..
            }
        }
开发者ID:Rodrigossz,项目名称:CloudDataCamp,代码行数:32,代码来源:DocumentDBDataReader.cs

示例7: GetDocumentCollection

        //SELECT C.id AS CourseId, C.Name AS CourseName
        //from CourseCollection AS C
        //Join Session IN C.Sessions
        //WHERE Session.Name = "Introduction"

        #region Helpers
        private static async Task<DocumentCollection> GetDocumentCollection(DocumentClient client, Database database)
        {
            DocumentCollection documentCollection = client.CreateDocumentCollectionQuery(database.CollectionsLink).Where(c => c.Id == "CourseCollection").AsEnumerable().FirstOrDefault();
            if (documentCollection == null)
            {
                documentCollection = await client.CreateDocumentCollectionAsync(database.CollectionsLink, new DocumentCollection() { Id = "CourseCollection" });
            }
            return documentCollection;
        }
开发者ID:mkhodary,项目名称:Azure_DocumentDB,代码行数:15,代码来源:Program.cs

示例8: GetDocumentCollection

 private static DocumentCollection GetDocumentCollection(DocumentClient client, Database database)
 {
     var documentCollection = client
         .CreateDocumentCollectionQuery(database.CollectionsLink)
         .Where(c => c.Id == "Documents")
         .AsEnumerable()
         .FirstOrDefault();
     return documentCollection;
 }
开发者ID:keesschollaart81,项目名称:DocumentDbSerializationTest,代码行数:9,代码来源:Program.cs

示例9: ReadOrCreateCollection

        internal static DocumentCollection ReadOrCreateCollection(DocumentClient client, string databaseLink, string collectionId)
        {
            var collections = client.CreateDocumentCollectionQuery(databaseLink)
                            .Where(col => col.Id == collectionId).ToArray();

            if (collections.Any())
            {
                return collections.First();
            }

            var collection = new DocumentCollection { Id = collectionId };
            return client.CreateDocumentCollectionAsync(databaseLink, collection).Result;
        }
开发者ID:alphio,项目名称:DocumentDB.AspNet.Identity,代码行数:13,代码来源:Utils.cs

示例10: Main

        static void Main(string[] args)
        {
            if (args.Count() < 4)
            {
                Console.WriteLine("You must specify the following parameters: Document DB endpoint URL, secret key, database name, and collection name.");
                Console.WriteLine("Program terminated. Press any key to exit");
                Console.ReadKey();
                return; // exit program

            }

            // setup DocumentDB client using passed parameters
            Uri endpoint = new Uri(args[0]);
            string authKey = args[1];
            string databaseId = args[2];
            string collectionId = args[3];

            var connectionPolicy = new ConnectionPolicy()
            {
                ConnectionProtocol = Protocol.Https,
                ConnectionMode = ConnectionMode.Gateway
            };
            client = new DocumentClient(endpoint, authKey, connectionPolicy);

            Database database = client.CreateDatabaseQuery().Where(db => db.Id == databaseId).ToArray().FirstOrDefault();
            DocumentCollection collection = client.CreateDocumentCollectionQuery(database.SelfLink).Where(c => c.Id == collectionId).ToArray().FirstOrDefault();

            // get list of SP files
            var currentDir = new DirectoryInfo(Directory.GetCurrentDirectory());
            foreach (FileInfo tmpFile in currentDir.GetFiles("SP_*.js"))
            {
                string storedProecureId = tmpFile.Name.Substring(3, (tmpFile.Name.Length - 6));
                Console.WriteLine("Found File: " + storedProecureId);

                var storedProc = new StoredProcedure()
                {
                    Id = storedProecureId,
                    Body = File.ReadAllText(tmpFile.FullName)
                };

                TryDeleteStoredProcedure(collection.SelfLink, storedProc.Id); 

                client.CreateStoredProcedureAsync(collection.SelfLink, storedProc, null).Wait();
            }

            Console.WriteLine("Stored Procedure Setup completed. Press any key to continue.");
            Console.ReadKey();
        }
开发者ID:hpatel98,项目名称:SCAMP,代码行数:48,代码来源:Program.cs

示例11: BackupPostAll

        public static async Task BackupPostAll()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudTableClient c = storageAccount.CreateCloudTableClient();
            _table = c.GetTableReference("Post");
            _table.CreateIfNotExists();

            _client = new DocumentClient(new Uri(EndpointUrl), AuthorizationKey);
            var database = await DocumentDB.GetDB(_client);

            IEnumerable<DocumentCollection> dz = _client.CreateDocumentCollectionQuery(database.SelfLink)
               .AsEnumerable();
            foreach (var x in dz)
            {
               await BackupPostCollection(x);
            }
        }
开发者ID:tzkwizard,项目名称:ELS,代码行数:17,代码来源:BackupPost.cs

示例12: WriteDocument

        public async Task<bool>  WriteDocument(MessageType type, String jsonString)
        {
            var client = new DocumentClient(new Uri(ConfigurationManager.AppSettings["DocumentServiceEndpoint"]), ConfigurationManager.AppSettings["DocumentKey"]);

            var dbName = ConfigurationManager.AppSettings["DocumentDatabase"];
            var database = client.CreateDatabaseQuery().Where(db => db.Id == dbName).AsEnumerable().FirstOrDefault() ??
                           await client.CreateDatabaseAsync(new Database{ Id = dbName});


            // Check to verify a document collection with the does not exist
            var docCollection = ConfigurationManager.AppSettings["DocumentCollection"];
            var documentCollection = client.CreateDocumentCollectionQuery(database.CollectionsLink).Where(c => c.Id == docCollection).AsEnumerable().FirstOrDefault() ??
                                     await client.CreateDocumentCollectionAsync(database.CollectionsLink, new DocumentCollection { Id = docCollection });

            var id = Guid.NewGuid().ToString();

            var response = HttpStatusCode.Unused;
            switch (type)
            {
                case MessageType.Energy:
                    var energyDoc = JsonConvert.DeserializeObject<EnergyDocument>(jsonString);
                    energyDoc.id = id;
                    response = (await client.CreateDocumentAsync(documentCollection.DocumentsLink, energyDoc)).StatusCode;
                    break;
                case MessageType.Humidity:
                    var humidityDoc = JsonConvert.DeserializeObject<HumidityDocument>(jsonString);
                    humidityDoc.id = id;
                    response = (await client.CreateDocumentAsync(documentCollection.DocumentsLink, humidityDoc)).StatusCode;
                    break;
                case MessageType.Light:
                    var lightDoc = JsonConvert.DeserializeObject<LightDocument>(jsonString);
                    lightDoc.id = id;
                    response = (await client.CreateDocumentAsync(documentCollection.DocumentsLink, lightDoc)).StatusCode;
                    break;
                case MessageType.Temperature:
                    var tempDoc = JsonConvert.DeserializeObject<TemperatureDocument>(jsonString);
                    tempDoc.id = id;
                    response = (await client.CreateDocumentAsync(documentCollection.DocumentsLink, tempDoc)).StatusCode;
                    break;
            }

            return response == HttpStatusCode.Created;
        }
开发者ID:karalamalar,项目名称:CloudDataCamp,代码行数:43,代码来源:DocumentDBWriter.cs

示例13: Main

        static void Main(string[] args)
        {
            ConnectionPolicy policy = new ConnectionPolicy()
            {
                ConnectionMode = ConnectionMode.Direct,
                ConnectionProtocol = Protocol.Tcp
            };
            Uri endPoint = new Uri(EndpointUrl);
            using (DocumentClient client = new DocumentClient(endPoint, AuthKey, policy))
            {
                Database database =
                    client.CreateDatabaseQuery().Where(db => db.Id == DatabasebId).AsEnumerable().First();
                DocumentCollection collection =
                    client.CreateDocumentCollectionQuery(database.SelfLink)
                        .Where(c => c.Id == CollectionId)
                        .AsEnumerable()
                        .First();

                IEnumerable<DataClass> dataSet = GetDataObjects(100);

                Task<ResourceResponse<Document>>[] documentTasks =
                    dataSet.Select(d => client.CreateDocumentAsync(collection.DocumentsLink, d)).ToArray();

                Task.WaitAll(documentTasks);

                Document[] docs = documentTasks.Select(t => t.Result.Resource).ToArray();

                Document doc = docs.First();

                Task<ResourceResponse<Attachment>>[] attachmentTasks =
                    docs.Select(d => client.CreateAttachmentAsync(doc.AttachmentsLink, GetStream(1024))).ToArray();

                Task.WaitAll(attachmentTasks);

                DataClass[] data =
                    client.CreateDocumentQuery<DataClass>(collection.DocumentsLink).Select(d => d).ToArray();
                Attachment[] attachments = client.CreateAttachmentQuery(doc.AttachmentsLink).ToArray();

                string sql = "SELECT c.Name FROM c Where c.ObjectKey < 30 AND c.ObjectKey > 20";
                dynamic[] dataArray = client.CreateDocumentQuery(collection.DocumentsLink, sql).ToArray();
            }
        }
开发者ID:pospanet,项目名称:OpenAlt_2015,代码行数:42,代码来源:Program.cs

示例14: GetOrCreateCollection

        private static DocumentCollection GetOrCreateCollection(DocumentClient client, string databaseSelfLink, string collectionName)
        {
            // Try to retrieve the collection (Microsoft.Azure.Documents.DocumentCollection) whose Id is equal to collectionName
            var collection = client.CreateDocumentCollectionQuery(databaseSelfLink)
                .Where(c => c.Id == collectionName)
                .ToArray()
                .FirstOrDefault()
                             ??
                             client.CreateDocumentCollectionAsync(databaseSelfLink,
                                 new DocumentCollection { Id = collectionName }).Result;

            if (collection == null)
            {
                collection = new DocumentCollection { Id = collectionName };
                collection.IndexingPolicy.IncludedPaths.Add(new IndexingPath { IndexType = IndexType.Range, NumericPrecision = 5, Path = "/" });

                collection = client.CreateDocumentCollectionAsync(databaseSelfLink, collection).Result;
            }
            return collection;
        }
开发者ID:spederiva,项目名称:AzureOss,代码行数:20,代码来源:UsersController.cs

示例15: Get

        // GET /api/search/?criterias=TOTO
        public List<FeedItem> Get([FromUri]string criterias = "")
        {
            // si criterias = LAST10 -> renvoyé les dix derniere articles

            var client = new DocumentClient(new Uri(EndpointUrl), AuthorizationKey);

            Database database = client.CreateDatabaseQuery()
                .Where(db => db.Id == databaseId)
                .AsEnumerable()
                .FirstOrDefault();

            DocumentCollection collectionPosts = client.CreateDocumentCollectionQuery(database.CollectionsLink)
                .Where(doccoll => doccoll.Id == collectionIdPost)
                .AsEnumerable()
                .FirstOrDefault();

            var posts  = (
                from b in client.CreateDocumentQuery<FeedItem>(collectionPosts.SelfLink)
                where b.Year == 2015 && b.Month >= 1 && b.Day >= 8
                select b).ToList();

            return posts;
        }
开发者ID:flyingoverclouds,项目名称:TD15FR-BackOfficePourApplicationMobile,代码行数:24,代码来源:SearchController.cs


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