public void can_populate_parent_collection_lazily_on_select() { using (var session = _factory.OpenSession()) { var department = new Department(); department.Name = "Math"; department.Number = "M100"; department.Description = "Mathematics"; var course = department.CreateCourse("101", "Introduction to Geometry", "Teaches basic concepts and theory of geometry."); var anInstructor = department.CreateInstructor(); anInstructor.Name.FirstName = "Joe"; anInstructor.Name.LastName = "Smith"; session.Save(department); var fromDb = session.Get <Department>(department.Id); // touching the instructors collection causes the lazy load: foreach (var instructor in fromDb.Instructors) { System.Diagnostics.Debug.WriteLine("Instructor: {0} {1} {2}", instructor.Id, instructor.Name.FirstName, instructor.Name.LastName); } Assert.Equal(department.Instructors.Count, fromDb.Instructors.Count); } }
public void can_find_entity_by_query_when_entity_is_defined_by_mapping_class() { using (var session = _factory.OpenSession(Connection)) using (var txn = session.BeginTransaction()) { var department = new Department { Description = "Math", Name = "Math", Number = "101" }; session.Save(department); txn.Commit(); var fromQuery = session.QueryOver <Department>() .Where((d) => d.Description == "Math") .Select().FirstOrDefault(); Assert.NotNull(fromQuery); } }