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


C# Document.Company类代码示例

本文整理汇总了C#中Raven.Client.Tests.Document.Company的典型用法代码示例。如果您正苦于以下问题:C# Company类的具体用法?C# Company怎么用?C# Company使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Company类属于Raven.Client.Tests.Document命名空间,在下文中一共展示了Company类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_Using_Sharded_Servers

        public When_Using_Sharded_Servers()
		{
            server = "localhost";

            port1 = 8080;
            port2 = 8081;

            path1 = GetPath("TestShardedDb1");
            path2 = GetPath("TestShardedDb2");

            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port1);
            NonAdminHttp.EnsureCanListenToWhenInNonAdminContext(port2);

            company1 = new Company { Name = "Company1" };
            company2 = new Company { Name = "Company2" };

            server1 = GetNewServer(port1, path1);
            server2 = GetNewServer(port2, path2);
 
            shards = new Shards { 
                new DocumentStore { Identifier="Shard1", Url = "http://" + server +":"+port1}, 
                new DocumentStore { Identifier="Shard2", Url = "http://" + server +":"+port2} 
            };

            shardSelection = MockRepository.GenerateStub<IShardSelectionStrategy>();
            shardSelection.Stub(x => x.ShardIdForNewObject(company1)).Return("Shard1");
            shardSelection.Stub(x => x.ShardIdForNewObject(company2)).Return("Shard2");

            shardResolution = MockRepository.GenerateStub<IShardResolutionStrategy>();

            shardStrategy = MockRepository.GenerateStub<IShardStrategy>();
            shardStrategy.Stub(x => x.ShardSelectionStrategy).Return(shardSelection);
            shardStrategy.Stub(x => x.ShardResolutionStrategy).Return(shardResolution);
        }
开发者ID:ajaishankar,项目名称:ravendb,代码行数:34,代码来源:When_Using_Sharded_Servers.cs

示例2: WhenDocumentAlreadyExists_Can_Still_Generate_Values

        public void WhenDocumentAlreadyExists_Can_Still_Generate_Values()
        {
            using (var store = NewDocumentStore())
            {
                var mk = new MultiTypeHiLoKeyGenerator(store.DatabaseCommands, 5);
                store.Conventions.DocumentKeyGenerator = o => mk.GenerateDocumentKey(store.Conventions, o);

                
                using (var session = store.OpenSession())
                {
                    var company = new Company();
                    session.Store(company);
                    var contact = new Contact();
                    session.Store(contact);

                    Assert.Equal("companies/1", company.Id);
                    Assert.Equal("contacts/1", contact.Id);
                }

                mk = new MultiTypeHiLoKeyGenerator(store.DatabaseCommands, 5);
                store.Conventions.DocumentKeyGenerator = o => mk.GenerateDocumentKey(store.Conventions, o);

                using (var session = store.OpenSession())
                {
                    var company = new Company();
                    session.Store(company);
                    var contact = new Contact();
                    session.Store(contact);

                    Assert.Equal("companies/6", company.Id);
                    Assert.Equal("contacts/6", contact.Id);
                }
            }
        }
开发者ID:VirtueMe,项目名称:ravendb,代码行数:34,代码来源:ClientKeyGeneratorTests.cs

示例3: Can_delete_by_index

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

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

					session.LuceneQuery<Company>().WaitForNonStaleResults().ToArray();// wait for the index to settle down
				}

				documentStore.DatabaseCommands.DeleteByIndex("Raven/DocumentsByEntityName", new IndexQuery
				{
					Query = "Tag:[[Companies]]"
				}, allowStale: false);

				using (var session = documentStore.OpenSession())
				{
					Assert.Empty(session.LuceneQuery<Company>().WaitForNonStaleResults().ToArray());
				}
			}
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:27,代码来源:DocumentStoreServerTests.cs

示例4: Can_insert_sync_and_get_async

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

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

				using (var session = documentStore.OpenAsyncSession())
				{
					var asyncResult = session.BeginLoad(entity.Id, null, null);
					if (asyncResult.CompletedSynchronously == false)
						asyncResult.AsyncWaitHandle.WaitOne();

					var company = session.EndLoad<Company>(asyncResult);
					Assert.Equal("Async Company", company.Name);
				}
			}
		}
开发者ID:Rationalle,项目名称:ravendb,代码行数:25,代码来源:AsyncDocumentStoreServerTests.cs

示例5: Will_get_notification_when_reading_non_authoritive_information

		public void Will_get_notification_when_reading_non_authoritive_information()
		{
			using (var documentStore = NewDocumentStore())
			{
				var company = new Company { Name = "Company Name" };
				var session = documentStore.OpenSession();
				using (var original = documentStore.OpenSession())
				{
					original.Store(company);
					original.SaveChanges();
				}
				using ( new TransactionScope())
				{
					company.Name = "Another Name";
					session.Store(company);
					session.SaveChanges();

					using (new TransactionScope(TransactionScopeOption.Suppress))
					{
						using (var session2 = documentStore.OpenSession())
						{
							session2.AllowNonAuthoritiveInformation = false;
							Assert.Throws<NonAuthoritiveInformationException>(()=>session2.Load<Company>(company.Id));
						}
					}
				}
			}
		}
开发者ID:markrendle,项目名称:ravendb,代码行数:28,代码来源:DocumentStoreEmbeddedTests.cs

示例6: Can_project_from_index

        public void Can_project_from_index()
        {
            using (var documentStore = NewDocumentStore())
            {
                var session = documentStore.OpenSession();
                var company = new Company { Name = "Company 1", Phone = 5};
                session.Store(company);
                session.SaveChanges();

                documentStore.DatabaseCommands.PutIndex("company_by_name",
                                                        new IndexDefinition
                                                        {
                                                            Map = "from doc in docs where doc.Name != null select new { doc.Name, doc.Phone}",
                                                            Stores = {{"Name", FieldStorage.Yes}, {"Phone",FieldStorage.Yes}}
                                                        });

                var q = session
                    .Query<Company>("company_by_name")
                    .SelectFields<Company>("Name", "Phone")
                    .WaitForNonStaleResults();
                var single = q.Single();
                Assert.Equal("Company 1", single.Name);
                Assert.Equal(5, single.Phone);
            }
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:25,代码来源:DocumentStoreEmbeddedTests.cs

示例7: Can_insert_into_two_servers_running_simultaneously_without_sharding

        public void Can_insert_into_two_servers_running_simultaneously_without_sharding()
        {
            var serversStoredUpon = new List<string>();

            using (var server1 = GetNewServer(port1, path1))
            using (var server2 = GetNewServer(port2, path2))
            {
                foreach (var port in new[] { port1, port2 })
                {
                    using (var documentStore = new DocumentStore { Url = "http://localhost:"+ port }.Initialise())
                    using (var session = documentStore.OpenSession())
                    {
                        documentStore.Stored += (storeServer, storeEntity) => serversStoredUpon.Add(storeServer);

                        var entity = new Company { Name = "Company" };
                        session.Store(entity);
                        session.SaveChanges();
                        Assert.NotEqual(Guid.Empty.ToString(), entity.Id);
                    }
                }
            }

            Assert.Contains(port1.ToString(), serversStoredUpon[0]);
            Assert.Contains(port2.ToString(), serversStoredUpon[1]);
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:25,代码来源:When_Using_Multiple_Unsharded_Servers.cs

示例8: IdIsSetFromGeneratorOnStore

        public void IdIsSetFromGeneratorOnStore()
        {
            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    Company company = new Company();
                    session.Store(company);

                    Assert.Equal("companies/1", company.Id);
                }
            }
        }
开发者ID:dplaskon,项目名称:ravendb,代码行数:13,代码来源:ClientKeyGeneratorTests.cs

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

示例10: DifferentTypesWillHaveDifferentIdGenerators

        public void DifferentTypesWillHaveDifferentIdGenerators()
        {
            using (var store = NewDocumentStore())
            {
                using (var session = store.OpenSession())
                {
                    var company = new Company();
                    session.Store(company);
                    var contact = new Contact();
                    session.Store(contact);

                    Assert.Equal("companies/1", company.Id);
                    Assert.Equal("contacts/1", contact.Id);
                }
            }
        }
开发者ID:dplaskon,项目名称:ravendb,代码行数:16,代码来源:ClientKeyGeneratorTests.cs

示例11: After_tx_rollback_value_will_not_be_in_the_database

        public void After_tx_rollback_value_will_not_be_in_the_database()
        {
            using (var documentStore = NewDocumentStore())
            {
                var company = new Company { Name = "Company Name" };
                var session = documentStore.OpenSession();
                using (new TransactionScope())
                {
                    session.Store(company);
                    session.SaveChanges();

                }
                using (var session2 = documentStore.OpenSession())
                    Assert.Null(session2.Load<Company>(company.Id));
            }
        }
开发者ID:kenegozi,项目名称:ravendb,代码行数:16,代码来源:DocumentStoreEmbeddedTests.cs

示例12: TotalResultIsIncludedInQueryResult

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

                    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.Advanced.LuceneQuery<Company>().WaitForNonStaleResults().QueryResult.TotalResults;
                        Assert.Equal(2, resultCount);
                    }
                }
            }
              
           

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

示例13: Can_refresh_entity_from_database

        public void Can_refresh_entity_from_database()
        {
            using (var documentStore = NewDocumentStore())
            {
                var company = new Company {Name = "Company Name"};
                var session = documentStore.OpenSession();
                session.Store(company);
                session.SaveChanges();

                var session2 = documentStore.OpenSession();
                var company2 = session2.Load<Company>(company.Id);
                company2.Name = "Hibernating Rhinos";
                session2.Store(company2);
                session2.SaveChanges();

                session.Refresh(company);

                Assert.Equal(company2.Name, company.Name);
              
            }
        }
开发者ID:nathanpalmer,项目名称:ravendb,代码行数:21,代码来源:DocumentStoreEmbeddedTests.cs

示例14: Can_use_transactions_to_isolate_saves

		public void Can_use_transactions_to_isolate_saves()
		{
			using (var documentStore = NewDocumentStore())
			{
				var company = new Company { Name = "Company Name" };
				var session = documentStore.OpenSession();
				using (RavenTransactionAccessor.StartTransaction())
				{
					session.Store(company);
					session.SaveChanges();

					using (RavenTransactionAccessor.StartTransaction())
					{
						using (var session2 = documentStore.OpenSession())
							Assert.Null(session2.Load<Company>(company.Id));
					}
					Assert.NotNull(session.Load<Company>(company.Id)); 
					documentStore.DatabaseCommands.Commit(RavenTransactionAccessor.GetTransactionInformation().Id);
				}
				Assert.NotNull(session.Load<Company>(company.Id));
			}
		}
开发者ID:VirtueMe,项目名称:ravendb,代码行数:22,代码来源:ExplicitTransaction.cs

示例15: Can_use_transactions_to_isolate_saves

        public void Can_use_transactions_to_isolate_saves()
        {
            using (var documentStore = NewDocumentStore())
            {
                var company = new Company { Name = "Company Name" };
                var session = documentStore.OpenSession();
                using (var tx = new TransactionScope())
                {
                    session.Store(company);
                    session.SaveChanges();

                    using (new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        using (var session2 = documentStore.OpenSession())
                            Assert.Null(session2.Load<Company>(company.Id));

                        tx.Complete();
                    }
                }
                Assert.NotNull(session.Load<Company>(company.Id));
            }  
        }
开发者ID:dplaskon,项目名称:ravendb,代码行数:22,代码来源:DocumentStoreEmbeddedTests.cs


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