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


C# DocumentStore.Initialise方法代码示例

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


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

示例1: 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.Initialise();
                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.Query<LinqIndexesFromClient.User>("UsersByLocation")
                        .Where("Name:Yael")
                        .WaitForNonStaleResults()
                        .Single();

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

示例2: Main

        static void Main(string[] args)
        {
            using (var documentStore = new DocumentStore { Url = "http://localhost:8080" })
            {
                documentStore.Initialise();
                //documentStore.DatabaseCommands.PutIndex("regionIndex",
                //                                        new IndexDefinition
                //                                        {
                //                                            Map = "from company in docs.Companies select new{company.Region}"
                //                                        });
                using (var session = documentStore.OpenSession())
            {

                session.Store(new Company { Name = "Company 1", Region = "Asia" });
                session.Store(new Company { Name = "Company 2", Region = "Africa" });
                session.SaveChanges();

                var allCompanies = session
                    .Query<Company>("regionIndex")
                    .Where("Region:Africa")
                    .WaitForNonStaleResults()
                    .ToArray();

                foreach (var company in allCompanies)
                    Console.WriteLine(company.Name);
            }}
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:27,代码来源:Program.cs

示例3: AddCountSoldtoAlbum

        public ActionResult AddCountSoldtoAlbum()
        {
            using (var documentStore = new DocumentStore {  Url = "http://localhost:8080" })
            {
                documentStore.Initialise();
                using (var session = documentStore.OpenSession())
                {
                    int count = 0;
                    do
                    {
                        var albums = session.LuceneQuery<Album>()
                            .Skip(count)
                            .Take(128)
                            .ToArray();
                        if (albums.Length == 0)
                            break;

                        foreach (var album in albums)
                        {
                            var result = session.LuceneQuery<SoldAlbum>("SoldAlbums")
                                .Where("Album:" + album.Id)
                                .SingleOrDefault();

                            album.CountSold = result == null ? 0 : result.Quantity;
                        }

                        count += albums.Length;

                        session.SaveChanges();
                        session.Clear();
                    } while (true); 
                }
            }
            return Content("OK");
        }
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:35,代码来源:HomeController.cs

示例4: Versioning

 public Versioning()
 {
     path = Path.GetDirectoryName(Assembly.GetAssembly(typeof (Versioning)).CodeBase);
     path = Path.Combine(path, "TestDb").Substring(6);
     if (Directory.Exists(path))
         Directory.Delete(path, true);
     ravenDbServer = new RavenDbServer(
         new RavenConfiguration
         {
             Port = 58080,
             DataDirectory = path,
             RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true,
             Catalog =
             {
                 Catalogs =
             {
                 new AssemblyCatalog(typeof (VersioningPutTrigger).Assembly)
             }
             },
             Settings =
             {
                 {"Raven/Versioning/MaxRevisions", "5"},
                 {"Raven/Versioning/Exclude", "Users;Comments;"}
             }
         });
     documentStore = new DocumentStore
     {
         Url = "http://localhost:58080"
     };
     documentStore.Initialise();
 }
开发者ID:kenegozi,项目名称:ravendb,代码行数:31,代码来源:Versioning.cs

示例5: Application_Start

        protected void Application_Start()
        {
            _documentStore = new DocumentStore { Url = "http://localhost:8080/" };
            _documentStore.Initialise();

            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:9,代码来源:Global.asax.cs

示例6: ConnectToDocumentStore

 private static DocumentStore ConnectToDocumentStore()
 {
     var documentStore = new DocumentStore
                             {
                                 Url = "http://localhost:8080"
                             };
     documentStore.Initialise();
     return documentStore;
 }
开发者ID:kajaljatakia,项目名称:ncqrs,代码行数:9,代码来源:RavenDBTestBase.cs

示例7: Main

        static void Main(string[] args)
        {
            if (Directory.Exists("ravendb")) Directory.Delete("ravendb", true);
            var documentStore = new DocumentStore
            {
                Configuration =
                {
                    DataDirectory = "ravendb"
                }
            };
            documentStore.Initialise();
            documentStore.DatabaseCommands.PutIndex("FooByName",
                new IndexDefinition<Foo>()
                {
                    Map = docs => from doc in docs select new { Name = doc.Name }
                });

            var numberOfFoos = 10000;

            // Insert Foos
            using (var session = documentStore.OpenSession())
            {
                for (var i = 0; i < numberOfFoos; i++)
                {
                    var newFoo = new Foo { Name = i.ToString() };
                    session.Store(newFoo);
                }
                session.SaveChanges();
            }

            // Query a single foo to wait for the index
            using (var session = documentStore.OpenSession())
            {
                var foo = session.Query<Foo>("FooByName").Where("Name:1").WaitForNonStaleResults(TimeSpan.FromMinutes(1)).First();
            }
            Console.WriteLine("starting querying");
            // Query all foos twice
            for (var queryRun = 0; queryRun < 15; queryRun++)
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();
                for (var i = 0; i < numberOfFoos; i++)
                {
                    using (var session = documentStore.OpenSession())
                    {
                        var foo = session.Query<Foo>("FooByName").Where("Name:" + i.ToString()).First();
                    }
                }
                stopWatch.Stop();
                Console.WriteLine("{0}. run: Querying {1} Foos in {2} ({3}ms per query)", queryRun, numberOfFoos, stopWatch.Elapsed, stopWatch.ElapsedMilliseconds / numberOfFoos);
            }
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:52,代码来源:Program.cs

示例8: NewDocumentStore

		private DocumentStore NewDocumentStore()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			var documentStore = new DocumentStore
			{
				Configuration =
				{
					DataDirectory = path
				}
			};
			documentStore.Initialise();
			return documentStore;
		}
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:14,代码来源:Game.cs

示例9: Can_specify_cutoff_using_server

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

                documentStore.DatabaseCommands.Query("Raven/DocumentsByEntityName", new IndexQuery
                {
                    PageSize = 10,
                    Cutoff = DateTime.Now.AddHours(-1)
                });
            }
        }
开发者ID:codereflection,项目名称:ravendb,代码行数:14,代码来源:DocumentStoreServerTests.cs

示例10: Should_insert_into_db_and_set_id

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

				var session = documentStore.OpenSession();
				var entity = new Company {Name = "Company"};
				session.Store(entity);
				session.SaveChanges();
				Assert.NotEqual(Guid.Empty.ToString(), entity.Id);
			}
		}
开发者ID:codereflection,项目名称:ravendb,代码行数:14,代码来源:DocumentStoreServerTests.cs

示例11: NewDocumentStore

		private DocumentStore NewDocumentStore()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			var documentStore = new DocumentStore
			{
				Configuration =
					{
						RunInUnreliableYetFastModeThatIsNotSuitableForProduction =true,
						DataDirectory = path
					}
			};
			documentStore.Initialise();
			return documentStore;
		}
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:15,代码来源:TagCloud.cs

示例12: TotalResultIsIncludedInQueryResult

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

                    using (var session = store.OpenSession())
                    {
                        Company company1 = new Company()
                        {
                            Name = "Company1",
                            Address1 = "",
                            Address2 = "",
                            Address3 = "",
                            Contacts = new List<Contact>(),
                            Phone = 2
                        };
                        Company company2 = new Company()
                        {
                            Name = "Company2",
                            Address1 = "",
                            Address2 = "",
                            Address3 = "",
                            Contacts = new List<Contact>(),
                            Phone = 2
                        };

                        session.Store(company1);
                        session.Store(company2);
                        session.SaveChanges();
                    }

                    using (var session = store.OpenSession())
                    {
                        int resultCount = session.LuceneQuery<Company>().WaitForNonStaleResults().QueryResult.TotalResults;
                        Assert.Equal(2, resultCount);
                    }
                }
            }
              
           

        }
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:45,代码来源:TotalCountServerTest.cs

示例13: NewDocumentStore

		private DocumentStore NewDocumentStore()
		{
			path = Path.GetDirectoryName(Assembly.GetAssembly(typeof(DocumentStoreServerTests)).CodeBase);
			path = Path.Combine(path, "TestDb").Substring(6);
			var documentStore = new DocumentStore
			{
				Configuration =
					{
						RunInUnreliableYetFastModeThatIsNotSuitableForProduction =true,
						DataDirectory = path
					},
				Conventions =
					{
						FindTypeTagName = type => typeof(IServer).IsAssignableFrom(type) ? "Servers" : null
					}
			};
			documentStore.Initialise();
			return documentStore;
		}
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:19,代码来源:Inheritance.cs

示例14: Can_get_two_documents_in_one_call

        public void Can_get_two_documents_in_one_call()
        {
            using (var server = GetNewServer(port, path))
            {
                var documentStore = new DocumentStore("localhost", port);
                documentStore.Initialise();

                var session = documentStore.OpenSession();
                session.Store(new Company { Name = "Company A", Id = "1"});
                session.Store(new Company { Name = "Company B", Id = "2" });
                session.SaveChanges();

                var session2 = documentStore.OpenSession();

                var companies = session2.Load<Company>("1","2");
                Assert.Equal(2, companies.Length);
                Assert.Equal("Company A", companies[0].Name);
                Assert.Equal("Company B", companies[1].Name);
            }
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:20,代码来源:DocumentStoreServerTests.cs

示例15: Can_delete_document

        public void Can_delete_document()
        {
            using (var server = GetNewServer(port, path))
            {
                var documentStore = new DocumentStore("localhost", port);
                documentStore.Initialise();

                var session = documentStore.OpenSession();
                var entity = new Company { Name = "Company" };
                session.Store(entity);
                session.SaveChanges();

                using(var session2 = documentStore.OpenSession())
                    Assert.NotNull(session2.Load<Company>(entity.Id));

                session.Delete(entity);
                session.SaveChanges();

                using (var session3 = documentStore.OpenSession())
                    Assert.Null(session3.Load<Company>(entity.Id));
            }
        }
开发者ID:torkelo,项目名称:ravendb,代码行数:22,代码来源:DocumentStoreServerTests.cs


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