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); } } }
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(); } } }
public void Add(Category category) { category.Parent = this; Children.Add(category); }