コード例 #1
0
		public void can_index_on_a_reference2()
		{
			using (var store = new EmbeddableDocumentStore
			{
				RunInMemory = true
			})
			{

				store.Initialize();
				using (var session = store.OpenSession())
				{
					var category = new Category()
					{
						Name = "Parent"
					};

					category.Add(new Category()
					{
						Name = "Child"
					});

					session.Store(category);
					session.SaveChanges();
				}

				using (var session = store.OpenSession())
				{
					var results0 = session.Query<Category>()
						.Customize(x=>x.WaitForNonStaleResults(TimeSpan.FromHours(1)))
						.ToList();
					Assert.Equal(1, results0.Count);

					// WORKS
					var results1 = session.Query<Category>()
						.Customize(x => x.WaitForNonStaleResults())
						.Where(x => x.Children.Any(y => y.Name == "Child")).
						ToList();
					Assert.Equal(1, results1.Count);

					// FAILS
					var results2 = session.Query<Category>()
						.Customize(x => x.WaitForNonStaleResults())
						.Where(x => x.Children.Any(y => y.Parent.Name == "Parent"))
						.ToList();
					Assert.Equal(1, results2.Count);
				}
			}
		}
コード例 #2
0
ファイル: ConcurrencyTests.cs プロジェクト: j2jensen/ravendb
        public void Without_id_convention_with_transaction()
        {
            using (var store = NewDocumentStore(requestedStorage: "esent"))
            {
                EnsureDtcIsSupported(store);

                using (var session = store.OpenSession())
                {
                    var contact = new Category
                    {
                        Id = "categories/1",
                        Name = "Test category"
                    };

                    session.Store(contact);
                    session.SaveChanges();
                }

                using (var transaction = new TransactionScope())
                {
                    using (var session = store.OpenSession())
                    {
                        var category = session.Load<Category>("categories/1");

                        session.Delete(category);
                        session.SaveChanges();

                        var newCategory = new Category
                        {
                            Id = category.Id,
                            Name = category.Name + "Updated"
                        };

                        session.Store(newCategory);

                        //This works!
                        session.SaveChanges();
                    }

                    transaction.Complete();
                }
            }
        }
コード例 #3
0
ファイル: JsonReferences.cs プロジェクト: WimVergouwe/ravendb
			public void Add(Category category)
			{
				category.Parent = this;
				Children.Add(category);
			}