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


C# DocumentStore.Initialize方法代码示例

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


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

示例1: Can_perform_a_simple_where

		public IEnumerable<Task> Can_perform_a_simple_where()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			var entity = new Company { Name = "Async Company #1", Id = "companies/1" };
			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				session.Store(entity);
				yield return session.SaveChangesAsync();
			}

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
			var query = session.Query<Company>()
						.Where(x => x.Name == "Async Company #1")
						.ToListAsync();
				yield return query;

				Assert.AreEqual(1, query.Result.Count);
				Assert.AreEqual("Async Company #1", query.Result[0].Name);
			}
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:25,代码来源:AsyncLinqQueryTests.cs

示例2: Can_delete_an_index_async

		public IEnumerable<Task> Can_delete_an_index_async()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore {Url = Url + Port};
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			yield return documentStore.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.PutIndexAsync("Test", new IndexDefinition
				                       	{
				                       		Map = "from doc in docs.Companies select new { doc.Name }"
				                       	}, true);

			var verify_put = documentStore.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.GetIndexNamesAsync(0, 25);
			yield return verify_put;

			Assert.IsTrue(verify_put.Result.Contains("Test"));

			yield return documentStore.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.DeleteIndexAsync("Test");

			var verify_delete = documentStore.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.GetIndexNamesAsync(0, 25);
			yield return verify_delete;

			//NOTE: this is failing because Silverlight is caching the response from the first verification
			Assert.IsFalse(verify_delete.Result.Contains("Test"));
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:33,代码来源:Indexes.cs

示例3: Including_a_related_entity_should_avoid_hitting_the_server_twice

		public IEnumerable<Task> Including_a_related_entity_should_avoid_hitting_the_server_twice()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			var customer = new Customer { Name = "Customer #1", Id = "customer/1", Email = "someone[email protected]" };
			var order = new Order { Id = "orders/1", Note = "Hello", Customer = new DenormalizedReference { Id = customer.Id, Name = customer.Name } };
			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				session.Store(customer);
				session.Store(order);
				yield return session.SaveChangesAsync();
			}

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				var query = session.Advanced.AsyncLuceneQuery<Order>()
					.Include(x => x.Customer.Id)
					.WhereEquals("Id", "orders/1")
					.QueryResultAsync;
				yield return query;

				Assert.Equal("Hello", query.Result.Results[0].Value<string>("Note"));

				// NOTE: this call should not hit the server 
				var load = session.LoadAsync<Customer>(customer.Id);
				yield return load;

				Assert.Equal(1, session.Advanced.NumberOfRequests);
			}
		}
开发者ID:aduggleby,项目名称:ravendb,代码行数:33,代码来源:AsyncLuceneQueryTests.cs

示例4: Some_sample_data

		public IEnumerable<Task> Some_sample_data()
		{
			var store = new DocumentStore {Url = Url + Port};
			store.Initialize();

			using (var session = store.OpenAsyncSession())
			{
				Enumerable.Range(0, 25).ToList()
					.ForEach(i => session.Store(new Company {Id = "Companies/" + i, Name = i.ToString()}));

				Enumerable.Range(0, 250).ToList()
					.ForEach(i => session.Store(new Order { Id = "Orders/" + i, Note = i.ToString() }));

				Enumerable.Range(0, 100).ToList()
					.ForEach(i => session.Store(new Customer { Name = "Joe " + i}));

				Enumerable.Range(0, 75).ToList()
					.ForEach(i => session.Store(new Contact { FirstName = "Bob" + i, Surname = i.ToString() + "0101001" }));

				session.Store(new Customer { Name = "Henry"});
				session.Store(new Order { Note = "An order" });
				session.Store(new Company {Name = "My Company"});

				yield return session.SaveChangesAsync();
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:26,代码来源:Generate.cs

示例5: Should_not_cache_the_list_of_databases

		public IEnumerable<Task> Should_not_cache_the_list_of_databases()
		{
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();

			var first = GenerateNewDatabaseName();
			yield return documentStore.AsyncDatabaseCommands
				.EnsureDatabaseExistsAsync(first);

			var task = documentStore.AsyncDatabaseCommands
				.GetDatabaseNamesAsync();
			yield return task;

			Assert.IsTrue(task.Result.Contains(first));

			var second = GenerateNewDatabaseName();
			yield return documentStore.AsyncDatabaseCommands
				.EnsureDatabaseExistsAsync(second);

			var verify = documentStore.AsyncDatabaseCommands
				.GetDatabaseNamesAsync();
			yield return verify;

			Assert.IsTrue(verify.Result.Contains(second));
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:25,代码来源:AsyncDatabaseCommandsTests.cs

示例6: Can_test_two_conditions_in_a_where_clause

		public IEnumerable<Task> Can_test_two_conditions_in_a_where_clause()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				session.Store(new Company { Name = "Async Company", Phone = 55555, Id = "companies/1" });
				session.Store(new Company { Name = "Async Company", Phone = 12345, Id = "companies/2" });
				yield return session.SaveChangesAsync();
			}

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				var query = session.Query<Company>()
							.Where(x => x.Name == "Async Company" && x.Phone == 12345)
							.ToListAsync();
				yield return query;

				Assert.AreEqual(1, query.Result.Count);
				Assert.AreEqual(12345, query.Result[0].Phone);
			}
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:25,代码来源:AsyncLinqQueryTests.cs

示例7: Can_insert_async_and_multi_get_async

        public IEnumerable<Task> Can_insert_async_and_multi_get_async()
        {
            var dbname = GenerateNewDatabaseName();
            var documentStore = new DocumentStore {Url = Url + Port};
            documentStore.Initialize();
            yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

            var entity1 = new Company {Name = "Async Company #1"};
            var entity2 = new Company {Name = "Async Company #2"};
            using (var session_for_storing = documentStore.OpenAsyncSession(dbname))
            {
                session_for_storing.Store(entity1);
                session_for_storing.Store(entity2);
                yield return session_for_storing.SaveChangesAsync();
            }

            using (var session_for_loading = documentStore.OpenAsyncSession(dbname))
            {
                var task = session_for_loading.MultiLoadAsync<Company>(new[] {entity1.Id, entity2.Id});
                yield return task;

                Assert.Equal(entity1.Name, task.Result[0].Name);
                Assert.Equal(entity2.Name, task.Result[1].Name);
            }
        }
开发者ID:aduggleby,项目名称:ravendb,代码行数:25,代码来源:AsyncDocumentStoreServerTests.cs

示例8: Can_delete_an_attachment

		public IEnumerable<Task> Can_delete_an_attachment()
		{
			var store = new DocumentStore {Url = Url + Port};
			store.Initialize();

			var dbname = GenerateNewDatabaseName();
			yield return store.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			const string someData = "The quick brown fox jumps over the lazy dog";
			var encoding = new UTF8Encoding();
			var bytes = encoding.GetBytes(someData);

			yield return store.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.PutAttachmentAsync("123", Guid.Empty, bytes, null);

			yield return store.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.DeleteAttachmentAsync("123", null);

			var get = store.AsyncDatabaseCommands
				.ForDatabase(dbname)
				.GetAttachmentAsync("123");
			yield return get;
			
			Assert.AreEqual(null, get.Result);
		}
开发者ID:runesoerensen,项目名称:ravendb,代码行数:27,代码来源:Attachments.cs

示例9: Can_get_total_count

		public IEnumerable<Task> Can_get_total_count()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			var entity = new Company { Name = "Async Company #1", Id = "companies/1" };
			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				session.Store(entity);
				yield return session.SaveChangesAsync();
			}

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				RavenQueryStatistics stats;
				var query = session.Query<Company>()
					.Customize(x=>x.WaitForNonStaleResults())
					.Statistics(out stats)
					.Where(x => x.Name == "Async Company #1")
					.CountAsync();
				yield return query;

				Assert.AreEqual(1, query.Result);
			}
		}
开发者ID:runesoerensen,项目名称:ravendb,代码行数:27,代码来源:AsyncLinqQueryTests.cs

示例10: InitializeSession

		void InitializeSession()
		{
			var store = new DocumentStore { Url = Address };

			store.Initialize();

			Session = store.OpenAsyncSession();
		}
开发者ID:jaircazarin,项目名称:ravendb,代码行数:8,代码来源:Database.cs

示例11: Can_retrieve_statistics_for_the_default_database

		public IEnumerable<Task> Can_retrieve_statistics_for_the_default_database()
		{
			var store = new DocumentStore { Url = Url + Port };
			store.Initialize();

			var getStats = store.AsyncDatabaseCommands
				.GetStatisticsAsync();
			yield return getStats;

			Assert.IsNotNull(getStats.Result);
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:11,代码来源:Statistics.cs

示例12: Can_get_a_list_of_databases_async

		public IEnumerable<Task> Can_get_a_list_of_databases_async()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			var task = documentStore.AsyncDatabaseCommands.GetDatabaseNamesAsync();
			yield return task;

			Assert.IsTrue(task.Result.Contains(dbname));
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:12,代码来源:AsyncDatabaseCommandsTests.cs

示例13: Some_indexing_errors

		public IEnumerable<Task> Some_indexing_errors()
		{
			var store = new DocumentStore { Url = Url + Port };
			store.Initialize();

			yield return store.AsyncDatabaseCommands
				.PutIndexAsync("pagesByTitle2",
						new IndexDefinition
						{
							Map = @"
					from doc in docs
					where doc.type == ""page""
					select new {  f = 2 / doc.size };"
						}, true);

			yield return store.AsyncDatabaseCommands
			.PutAsync("1", null,
					   RavenJObject.Parse(
						@"{
								type: 'page', 
								some: 'val', 
								other: 'var', 
								content: 'this is the content', 
								title: 'hello world', 
								size: 0,
								'@metadata': {'@id': 1}
							}"),
					   new RavenJObject());

			for (int i = 0; i < 50; i++)
			{
				var query = store.AsyncDatabaseCommands
					.QueryAsync("pagesByTitle2", new IndexQuery
						{
							Query = "f:val",
							Start = 0,
							PageSize = 10
						}, null);
				yield return (query);

				if (query.Result.IsStale)
				{
					yield return Delay(100);
					continue;
				}
				Assert.AreNotEqual(0, query.Result.TotalResults);
				yield break;
			}
		}
开发者ID:925coder,项目名称:ravendb,代码行数:49,代码来源:Generate.cs

示例14: Can_get_index_names_async

		public IEnumerable<Task> Can_get_index_names_async()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore {Url = Url + Port};
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);
			yield return
				documentStore.AsyncDatabaseCommands.ForDatabase(dbname).PutIndexAsync("test", new IndexDefinition
				{
					Map = "from doc in docs select new { doc.Name}"
				}, true);
			var task = documentStore.AsyncDatabaseCommands.ForDatabase(dbname).GetIndexNamesAsync(0, 25);
			yield return task;

			Assert.IsTrue(task.Result.Any(x => x == "test"));
	
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:17,代码来源:Indexes.cs

示例15: Calling_ToList_raises_an_exception

		//[ExpectedException(typeof(NotSupportedException))]
		public IEnumerable<Task> Calling_ToList_raises_an_exception()
		{
			var dbname = GenerateNewDatabaseName();
			var documentStore = new DocumentStore { Url = Url + Port };
			documentStore.Initialize();
			yield return documentStore.AsyncDatabaseCommands.EnsureDatabaseExistsAsync(dbname);

			using (var session = documentStore.OpenAsyncSession(dbname))
			{
				//NOTE: shouldn't compile
				//var query = session.Query<Company>()
				//            .Where(x => x.Name == "Doesn't Really Matter")
				//            .ToList();

				// should compile
				var list = new List<string>().ToList();
			}
		}
开发者ID:philiphoy,项目名称:ravendb,代码行数:19,代码来源:AsyncLinqQueryTests.cs


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