public void TestLazyDynamicClass(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler) { ITransaction t; IDictionary cars; IList models; using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = new Hashtable(); cars["Description"] = "Cars"; IDictionary monaro = new Hashtable(); monaro["ProductLine"] = cars; monaro["Name"] = "Monaro"; monaro["Description"] = "Holden Monaro"; IDictionary hsv = new Hashtable(); hsv["ProductLine"] = cars; hsv["Name"] = "hsv"; hsv["Description"] = "Holden hsv"; models = new List <IDictionary> { monaro, hsv }; cars["Models"] = models; s.Save("ProductLine", cars); t.Commit(); } using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = singleCarQueryHandler(s); models = (IList)cars["Models"]; Assert.IsFalse(NHibernateUtil.IsInitialized(models)); Assert.AreEqual(2, models.Count); Assert.IsTrue(NHibernateUtil.IsInitialized(models)); s.Clear(); IList list = allModelQueryHandler(s); foreach (IDictionary ht in list) { Assert.IsFalse(NHibernateUtil.IsInitialized(ht["ProductLine"])); } var model = (IDictionary)list[0]; Assert.IsTrue(((IList)((IDictionary)model["ProductLine"])["Models"]).Contains(model)); s.Clear(); t.Commit(); } using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = singleCarQueryHandler(s); s.Delete(cars); t.Commit(); } }
public void TestLazyDynamicClass(SingleCarQueryDelegate singleCarQueryHandler, AllModelQueryDelegate allModelQueryHandler) { ITransaction t; using (ISession s = OpenSession()) { var si = (ISessionImplementor)s; Assert.IsTrue(si.EntityMode == EntityMode.Map, "Incorrectly handled default_entity_mode"); ISession other = s.GetSession(EntityMode.Poco); other.Close(); Assert.IsFalse(other.IsOpen); } IDictionary cars; IList models; using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = new Hashtable(); cars["Description"] = "Cars"; IDictionary monaro = new Hashtable(); monaro["ProductLine"] = cars; monaro["Name"] = "Monaro"; monaro["Description"] = "Holden Monaro"; IDictionary hsv = new Hashtable(); hsv["ProductLine"] = cars; hsv["Name"] = "hsv"; hsv["Description"] = "Holden hsv"; models = new List<IDictionary> {monaro, hsv}; cars["Models"] = models; s.Save("ProductLine", cars); t.Commit(); } using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = singleCarQueryHandler(s); models = (IList)cars["Models"]; Assert.IsFalse(NHibernateUtil.IsInitialized(models)); Assert.AreEqual(2, models.Count); Assert.IsTrue(NHibernateUtil.IsInitialized(models)); s.Clear(); IList list = allModelQueryHandler(s); foreach (IDictionary ht in list) { Assert.IsFalse(NHibernateUtil.IsInitialized(ht["ProductLine"])); } var model = (IDictionary)list[0]; Assert.IsTrue(((IList)((IDictionary)model["ProductLine"])["Models"]).Contains(model)); s.Clear(); t.Commit(); } using (ISession s = OpenSession()) { t = s.BeginTransaction(); cars = singleCarQueryHandler(s); s.Delete(cars); t.Commit(); } }