public void MainTest() { using (var session = Domain.OpenSession()) { using (var t = session.OpenTransaction()) { IPerson p = new Person1(); p.Pets.Add(new Animal1()); p.Pets.Add(new Animal1()); p.Pets.Add(new Animal2()); p = new Person2(); p.Pets.Add(new Animal1()); p.Pets.Add(new Animal1()); p.Pets.Add(new Animal2()); Session.Current.SaveChanges(); p = session.Query.All <IPerson>().First(); Assert.AreEqual(3, p.Pets.Count); var first = p.Pets.First(); first.Remove(); Assert.IsTrue(first.PersistenceState == PersistenceState.Removed); Assert.IsFalse(p.Pets.Contains(first)); Assert.AreEqual(2, p.Pets.Count); p.Remove(); session.Remove(session.Query.All <IAnimal>()); new Animal1() { PetName = "A" }; new Animal1() { PetName = "B" }; new Animal1() { PetName = "C" }; new Animal2() { PetName = "D" }; new Animal2() { PetName = "E" }; new Animal2() { PetName = "F" }; new Animal3() { PetName = "G" }; new Animal3() { PetName = "H" }; new Animal3() { PetName = "J" }; var animals = session.Query.All <IAnimal>(); Assert.AreEqual(9, animals.Count()); animals.Select(a => new { a.Id, a.PetName }).Where(x => x.Id != 0).ToList(); var list = session.Query.All <IAnimal>().Where(a => (string)a["PetName"] == "D").ToList(); Assert.AreEqual(1, list.Count); t.Complete(); } } }