Ejemplo n.º 1
0
        public void IncludeWithBadClrTypeShouldWorkForBothLoadsAndQueries()
        {
            using (var store = NewDocumentStore())
            {
                store.DatabaseCommands.Put("addresses/1", null, RavenJObject.FromObject(new Address { Street = "Street1" }), new RavenJObject());

                using (var session = store.OpenSession())
                {
                    var person = new Person { AddressId = "addresses/1", Name = "Name1" };
                    session.Store(person);

                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var person = session.Include<Person>(x => x.AddressId).Load<Person>("people/1");

                    Assert.NotNull(person);
                    Assert.Equal("Name1", person.Name);
                    Assert.Equal("addresses/1", person.AddressId);

                    Assert.Equal(1, session.Advanced.NumberOfRequests);

                    var address = session.Load<Address>(person.AddressId);

                    Assert.Equal("Street1", address.Street);

                    Assert.Equal(1, session.Advanced.NumberOfRequests);
                }

                using (var session = store.OpenSession())
                {
                    var people = session
                        .Query<Person>()
                        .Include(x => x.AddressId)
                        .Customize(x => x.WaitForNonStaleResults())
                        .ToList();

                    Assert.Equal(1, people.Count);

                    var person = people[0];

                    Assert.NotNull(person);
                    Assert.Equal("Name1", person.Name);
                    Assert.Equal("addresses/1", person.AddressId);

                    Assert.Equal(1, session.Advanced.NumberOfRequests);

                    var address = session.Load<Address>(person.AddressId);

                    Assert.Equal("Street1", address.Street);

                    Assert.Equal(1, session.Advanced.NumberOfRequests);
                }
            }
        }
Ejemplo n.º 2
0
		public void ShouldWork()
		{
			var one = CreateStore();
			var two = CreateStore();

			var random = new Random();
			var content = new byte[10000];
			random.NextBytes(content);

			string id = null;

			using (var s1 = one.OpenSession())
			{
				for (int i = 0; i < 10000; i++)
				{
					var item = new Item { Name = "ayende", Content = content };
					s1.Store(item);

					id = item.Id;
				}

				s1.SaveChanges();
			}

			// master / master
			TellFirstInstanceToReplicateToSecondInstance();

			Thread.Sleep(2000);

			for (int i = 0; i < 10; i++)
			{
				using (var s2 = two.OpenSession())
				{
					var item = new Person { Name = "ayende" };
					s2.Store(item);

					s2.SaveChanges();

					Thread.Sleep(500);
				}
			}

			WaitForReplication(two, id);

			using (var s2 = two.OpenSession())
			{
				var count = s2
					.Query<Result>("Raven/DocumentsByEntityName")
					.Customize(x => x.WaitForNonStaleResults())
					.Count(x => x.Tag == "Items");

				Assert.Equal(10000, count);
			}
		}
Ejemplo n.º 3
0
        public async Task<HttpResponseMessage> MarkReadOnly()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .MarkReadOnly(person);

            return new HttpResponseMessage();
        }
Ejemplo n.º 4
0
        public Task<HttpResponseMessage> GetDocumentUrl()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .GetDocumentUrl(person);
            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 5
0
		public HttpResponseMessage Refresh()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.SaveChanges();

			Session
				.Advanced
				.Refresh(person);

			return new HttpResponseMessage();
		}
Ejemplo n.º 6
0
		public HttpResponseMessage MarkReadOnly()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.MarkReadOnly(person);

			return new HttpResponseMessage();
		}
Ejemplo n.º 7
0
		public HttpResponseMessage IgnoreChangesFor()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.IgnoreChangesFor(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 8
0
		public HttpResponseMessage GetMetadataFor()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.GetMetadataFor(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 9
0
		public HttpResponseMessage ExplicitlyVersion()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.ExplicitlyVersion(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 10
0
        public Task<HttpResponseMessage> Refresh()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .SaveChanges();

            Session
                .Advanced
                .Refresh(person);

            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 11
0
        public Task<HttpResponseMessage> MarkReadOnly()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .MarkReadOnly(person);

            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 12
0
        public Task<HttpResponseMessage> IsLoaded()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .IsLoaded("people/1");
            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 13
0
        public Task<HttpResponseMessage> IgnoreChangesFor()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .IgnoreChangesFor(person);
            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 14
0
        public Task<HttpResponseMessage> GetMetadataFor()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .GetMetadataFor(person);
            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }
Ejemplo n.º 15
0
        public async Task<HttpResponseMessage> Refresh()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            await Session
                .SaveChangesAsync();

            await Session
                .Advanced
                .RefreshAsync(person);

            return new HttpResponseMessage();
        }
Ejemplo n.º 16
0
		public HttpResponseMessage Evict()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.Evict(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 17
0
        public async Task<HttpResponseMessage> ExplicitlyVersion()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .ExplicitlyVersion(person);
            return new HttpResponseMessage();
        }
Ejemplo n.º 18
0
		public HttpResponseMessage GetDocumentUrl()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.GetDocumentUrl(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 19
0
        public async Task<HttpResponseMessage> GetDocumentUrl()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .GetDocumentUrl(person);
            return new HttpResponseMessage();
        }
Ejemplo n.º 20
0
		public HttpResponseMessage HasChanged()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.HasChanged(person);
			return new HttpResponseMessage();
		}
Ejemplo n.º 21
0
        public async Task<HttpResponseMessage> GetMetadataFor()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .GetMetadataFor(person);
            return new HttpResponseMessage();
        }
Ejemplo n.º 22
0
		public HttpResponseMessage IsLoaded()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.IsLoaded("people/1");
			return new HttpResponseMessage();
		}
Ejemplo n.º 23
0
        public async Task<HttpResponseMessage> HasChanged()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .HasChanged(person);
            return new HttpResponseMessage();
        }
Ejemplo n.º 24
0
		public HttpResponseMessage MultiFacetedSearch()
		{
			var person = new Person();

			Session
				.Store(person);

			Session
				.Advanced
				.MultiFacetedSearch(new[]
				                    {
					                    new FacetQuery
					                    {
						                    IndexName = new RavenDocumentsByEntityName().IndexName, 
											Query = new IndexQuery(), 
											Facets = new List<Facet>
											         {
												         new Facet
												         {
													         Name = "Facet1", 
															 Mode = FacetMode.Default
												         }
											         }
					                    }
				                    });

			return new HttpResponseMessage();
		}
Ejemplo n.º 25
0
        public async Task<HttpResponseMessage> IgnoreChangesFor()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .IgnoreChangesFor(person);
            return new HttpResponseMessage();
        }
Ejemplo n.º 26
0
        public async Task<HttpResponseMessage> IsLoaded()
        {
            var person = new Person();

            await Session
                .StoreAsync(person);

            Session
                .Advanced
                .IsLoaded("people/1");
            return new HttpResponseMessage();
        }
Ejemplo n.º 27
0
        public Task<HttpResponseMessage> ExplicitlyVersion()
        {
            var person = new Person();

            Session
                .Store(person);

            Session
                .Advanced
                .ExplicitlyVersion(person);
            return new CompletedTask<HttpResponseMessage>(new HttpResponseMessage());
        }