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


C# DocumentStore.Initialize方法代码示例

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


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

示例1: CascadeDelete

        public CascadeDelete()
        {
            path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(CascadeDelete)).CodeBase);
            path = Path.Combine(path, "TestDb").Substring(6);
            database::Raven.Database.Extensions.IOExtensions.DeleteDirectory("Data");
            ravenDbServer = new RavenDbServer(
                new database::Raven.Database.Config.RavenConfiguration
                {
                    Port = 58080,
                    RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
                    DataDirectory = path,
                    Catalog =
                    {
                        Catalogs =
                                {
                                    new AssemblyCatalog(typeof (CascadeDeleteTrigger).Assembly)
                                }
                    },
                });

            documentStore = new DocumentStore
            {
                Url = "http://localhost:58080"
            };
            documentStore.Initialize();
        }
开发者ID:philiphoy,项目名称:ravendb,代码行数:26,代码来源:CascadeDelete.cs

示例2: GetRavenDBConnection

 public static IDocumentSession GetRavenDBConnection()
 {
     DocumentStore documentStore = new DocumentStore();
     documentStore.ConnectionStringName="RavenDB";
     documentStore.Initialize();
     return documentStore.OpenSession();
 }
开发者ID:ajaywhiz,项目名称:Cart5,代码行数:7,代码来源:RavenDBUtil.cs

示例3: CanOverwriteIndex

        public void CanOverwriteIndex()
        {
            using (var server = GetNewServer(port, path))
            {
                var store = new DocumentStore { Url = "http://localhost:" + port };
                store.Initialize();

                store.DatabaseCommands.PutIndex("test",
                                                new IndexDefinition
                                                {
                                                    Map = "from doc in docs select new { doc.Name }"
                                                }, overwrite: true);

                store.DatabaseCommands.PutIndex("test",
                                                new IndexDefinition
                                                {
                                                    Map = "from doc in docs select new { doc.Name }"
                                                }, overwrite: true);

                store.DatabaseCommands.PutIndex("test",
                                                new IndexDefinition
                                                {
                                                    Map = "from doc in docs select new { doc.Email }"
                                                }, overwrite: true);

                store.DatabaseCommands.PutIndex("test",
                                                new IndexDefinition
                                                {
                                                    Map = "from doc in docs select new { doc.Email }"
                                                }, overwrite: true);
            }
        }
开发者ID:vinone,项目名称:ravendb,代码行数:32,代码来源:OverwriteIndexRemotely.cs

示例4: CanReplicateBetweenTwoMultiTenantDatabases

		public void CanReplicateBetweenTwoMultiTenantDatabases()
		{
			using (var store = new DocumentStore
			                   	{
			                   		DefaultDatabase = "FailoverTest",
			                   		Url = store1.Url,
			                   		Conventions =
			                   			{
			                   				FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries
			                   			}
			                   	})
			{
				store.Initialize();
				var replicationInformerForDatabase = store.GetReplicationInformerForDatabase(null);
				var databaseCommands = (ServerClient) store.DatabaseCommands;
				replicationInformerForDatabase.UpdateReplicationInformationIfNeeded(databaseCommands)
					.Wait();

				var replicationDestinations = replicationInformerForDatabase.ReplicationDestinationsUrls;
				
				Assert.NotEmpty(replicationDestinations);

				using (var session = store.OpenSession())
				{
					session.Store(new Item());
					session.SaveChanges();
				}

				var sanityCheck = store.DatabaseCommands.Head("items/1");
				Assert.NotNull(sanityCheck);

				WaitForDocument(store2.DatabaseCommands.ForDatabase("FailoverTest"), "items/1");
			}
		}
开发者ID:denno-secqtinstien,项目名称:ravendb,代码行数:34,代码来源:FailoverBetweenTwoMultiTenantDatabases.cs

示例5: CanTrackPosts

		public void CanTrackPosts()
		{
			using (GetNewServer())
			using (var store = new DocumentStore { Url = "http://localhost:8080" })
			{
				store.Initialize();
				// make the replication check here
				using (var session = store.OpenSession())
				{
					session.Load<User>("users/1");
				}

				Guid id;
				using (var session = store.OpenSession())
				{
					session.Store(new User());
					session.SaveChanges();

					id = session.Advanced.DatabaseCommands.ProfilingInformation.Id;
				}

				var profilingInformation = store.GetProfilingInformationFor(id);

				Assert.Equal(1, profilingInformation.Requests.Count);
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:26,代码来源:Profiling.cs

示例6: Main

        static void Main(string[] args)
        {
            var store = new DocumentStore {Url = "http://localhost:8082"};
            store.Initialize();

            //store.DatabaseCommands.EnsureDatabaseExists("TestDb");

            //using(var session = store.OpenSession("TestDb"))
            //{
            //    var agency = new Agency();
            //    agency.Name = "TestAgency";

            //    session.Store(agency);
            //    session.SaveChanges();
            //}

            using (var session = store.OpenSession("TestDb"))
            {
                var agency = session.Query<Agency>()
                    .Where(a => a.Name == "TestAgency")
                    .SingleOrDefault();

                if (agency != null)
                    Console.WriteLine(agency.Name);

            }

            Console.ReadLine();
        }
开发者ID:gan123,项目名称:RightRecruit,代码行数:29,代码来源:Program.cs

示例7: RavenDbRegistry

        public RavenDbRegistry(string connectionStringName)
        {
            For<IDocumentStore>()
                .Singleton()
                .Use(x =>
                         {
                             var store = new DocumentStore
                                             {
                                                 ConnectionStringName = connectionStringName,
                                             };
                             store.Initialize();

                             // Index initialisation.
                             IndexCreation.CreateIndexes(typeof(RecentTags).Assembly, store);

                             return store;
                         }
                )
                .Named("RavenDB Document Store.");

            For<IDocumentSession>()
                .AlwaysUnique()
                .Use(x =>
                         {
                             var store = x.GetInstance<IDocumentStore>();
                             return store.OpenSession();
                         })
                .Named("RavenDB Session (aka. Unit of Work).");
        }
开发者ID:alexeylih,项目名称:RavenOverflow,代码行数:29,代码来源:RavenDbRegistry.cs

示例8: Application_Start

        protected void Application_Start()
        {
            DocumentStore = new DocumentStore
            {
                DefaultDatabase = "Polyglot.UI.Orders",
                Url = "http://localhost:8080"
            };
            DocumentStore.Initialize();

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            Bus = Configure
                .With()
                .DefaultBuilder()
                .XmlSerializer()
                .MsmqTransport()
                .UnicastBus()
                .SendOnly();
        }
开发者ID:calebjenkins,项目名称:presentations,代码行数:25,代码来源:Global.asax.cs

示例9: Index

        public ActionResult Index()
        {
            using (var documentStore = new DocumentStore { Url = "http://localhost:8080/", DefaultDatabase = "msftuservoice" })
            {
                documentStore.Initialize();

                IndexCreation.CreateIndexes(typeof(ByCategoryIndex).Assembly, documentStore);

               using(var session = documentStore.OpenSession())
               {
                   RavenQueryStatistics totalStats;
                   var resultTotal = session.Query<Suggestion>().
                       Statistics(out totalStats).
                       ToArray();

                   ViewBag.Total = totalStats.TotalResults;

                   RavenQueryStatistics dateStats;
                   var resultByDate = session.Query<ByDateIndex.ByDateResult, ByDateIndex>().Statistics(out dateStats).ToList();

                   var orderbyDate = resultByDate.OrderBy(x => x.ParsedDate).ToList();

                   string foobar = resultByDate.ToString();
               }
            }

            return View();
        }
开发者ID:Code-Inside,项目名称:BecauseWeCare,代码行数:28,代码来源:HomeController.cs

示例10: CompressionAndEncryption

		public CompressionAndEncryption()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(Versioning.Versioning)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			Raven.Database.Extensions.IOExtensions.DeleteDirectory(path);
			settings = new Raven.Database.Config.RavenConfiguration
			{
				Port = 8079,
				RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
				DataDirectory = path,
				Settings =
					{
						{"Raven/Encryption/Key", "3w17MIVIBLSWZpzH0YarqRlR2+yHiv1Zq3TCWXLEMI8="},
						{"Raven/ActiveBundles", "Compression;Encryption"}
					}
			};
			ConfigureServer(settings);
			settings.PostInit();
			ravenDbServer = new RavenDbServer(settings);
			documentStore = new DocumentStore
			{
				Url = "http://localhost:8079"
			};
			documentStore.Initialize();
		}
开发者ID:arelee,项目名称:ravendb,代码行数:25,代码来源:CompressionAndEncryption.cs

示例11: Can_create_index_using_linq_from_client

        public void Can_create_index_using_linq_from_client()
        {
            using (var server = GetNewServer(port, path))
            {
                var documentStore = new DocumentStore { Url = "http://localhost:" + port };
                documentStore.Initialize();
                documentStore.DatabaseCommands.PutIndex("UsersByLocation", new IndexDefinition<LinqIndexesFromClient.User>
                {
                    Map = users => from user in users
                                   where user.Location == "Tel Aviv"
                                   select new { user.Name },
                });

                using (var session = documentStore.OpenSession())
                {
                    session.Store(new LinqIndexesFromClient.User
                    {
                        Location = "Tel Aviv",
                        Name = "Yael"
                    });

                    session.SaveChanges();

                    LinqIndexesFromClient.User single = session.Advanced.LuceneQuery<LinqIndexesFromClient.User>("UsersByLocation")
                        .Where("Name:Yael")
                        .WaitForNonStaleResults()
                        .Single();

                    Assert.Equal("Yael", single.Name);
                }
            }
        }
开发者ID:vinone,项目名称:ravendb,代码行数:32,代码来源:DocumentStoreServerTests.cs

示例12: RavenDB_560

		public RavenDB_560()
		{
			server1DataDir = NewDataPath("D1");
			server2DataDir = NewDataPath("D2");
			server1 = CreateServer(8001, server1DataDir);
			server2 = CreateServer(8002, server2DataDir);


			store1 = new DocumentStore
			{
				DefaultDatabase = "Northwind",
				Url = "http://" + Environment.MachineName + ":8001",
			};
			store1.Initialize(false);

			store2 = new DocumentStore
			{
				DefaultDatabase = "Northwind",
				Url = "http://" + Environment.MachineName + ":8002"
			};
			store2.Initialize(false);


			store1.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument
			{
				Id = "Northwind",
				Settings = { { "Raven/ActiveBundles", "replication" }, { "Raven/DataDir", @"~\Databases1\Northwind" } }
			});

			store2.DatabaseCommands.GlobalAdmin.CreateDatabase(new DatabaseDocument
			{
				Id = "Northwind",
				Settings = { { "Raven/ActiveBundles", "replication" }, { "Raven/DataDir", @"~\Databases2\Northwind" } }
			});
		}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:35,代码来源:RavenDB_560.cs

示例13: Configure

        public static void Configure()
        {
            var builder = new ContainerBuilder();
            builder.RegisterControllers(Assembly.GetExecutingAssembly());

            //register RavenDb DocumentStore
            builder.Register(x =>
            {
                var store = new DocumentStore { ConnectionStringName = "RavenDb" };
                store.Initialize();
                IndexCreation.CreateIndexes(Assembly.GetCallingAssembly(), store);
                return store;
            });

            //register RavenDb DocumentSession per Http request and SaveChanges on release of scope
            builder.Register(x => x.Resolve<DocumentStore>().OpenSession())
                .As<IDocumentSession>()
                .InstancePerHttpRequest();
                   //.OnRelease(x => { using (x) { x.SaveChanges(); } });

            builder.RegisterType<SupplierNameResolver>().InstancePerHttpRequest();
            builder.RegisterType<CategoryNameResolver>().InstancePerHttpRequest();

            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
开发者ID:halcharger,项目名称:RavenDbNorthwindSpike,代码行数:26,代码来源:AutofacConfig.cs

示例14: AggressiveCaching

		public AggressiveCaching()
		{
			using (var documentStore = new DocumentStore { Url = "http://localhost:8080" })
			{
				documentStore.Initialize();

				#region should_cache_delegate
				documentStore.Conventions.ShouldCacheRequest = url => true;
				#endregion

				#region max_number_of_requests
				documentStore.MaxNumberOfCachedRequests = 2048;
				#endregion

				using (var session = documentStore.OpenSession())
				{
					#region aggressive_cache_load
					using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5)))
					{
						var user = session.Load<User>("users/1");
					}
					#endregion
				}

				using (var session = documentStore.OpenSession())
				{
					#region aggressive_cache_query
					using (session.Advanced.DocumentStore.AggressivelyCacheFor(TimeSpan.FromMinutes(5)))
					{
						var users = session.Query<User>().ToList();
					}
					#endregion
				}
			}
		}
开发者ID:modulexcite,项目名称:docs-8,代码行数:35,代码来源:AggressiveCaching.cs

示例15: CanAccessDbUsingDifferentNames

		public void CanAccessDbUsingDifferentNames()
		{
			using (GetNewServer())
			{
				using (var documentStore = new DocumentStore
				{
					Url = "http://localhost:8080"
				})
				{
					documentStore.Initialize();
					documentStore.DatabaseCommands.EnsureDatabaseExists("repro");
					using (var session = documentStore.OpenSession("repro"))
					{
						session.Store(new Foo
						{
							Bar = "test"
						});
						session.SaveChanges();
					}

					using (var session = documentStore.OpenSession("Repro"))
					{
						Assert.NotNull(session.Load<Foo>("foos/1"));
					}
				}
			}
		}
开发者ID:nzdunic,项目名称:ravendb,代码行数:27,代码来源:NoCaseSensitive.cs


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