public void Can_Write_Simple_Parent_Entity() { using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var parent = new TestEntityParent { Name = "Can_Write_Simple_Parent_Entity", Description = "Desc: Can_Write_Simple_Parent_Entity" }; session.Save(parent); transaction.Commit(); Assert.That(parent.Id, Is.Not.Null); } }
public void Can_Read_Parent_Entity_With_Child_No_Null_Check() { Guid parentId; using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var parent = new TestEntityParent { Name = "Can_Read_Parent_Entity_With_Child_No_Null_Check", Description = "Desc: Can_Read_Parent_Entity_With_Child_No_Null_Check", Child = new TestEntityChild { Name = "Can_Read_Parent_Entity_With_Child_No_Null_Check - Child", Description = "Desc: Can_Read_Parent_Entity_With_Child_No_Null_Check - Child", NumberOfApples = 62256897 } }; session.Save(parent); transaction.Commit(); parentId = parent.Id; Assert.That(parent.Id, Is.Not.Null); } using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var query = session.Query <TestEntityParent>() .Where(x => x.Id == parentId) .Select(m => new ParentModel { Id = m.Id, Name = m.Name, Child = new ChildModel { Id = m.Child.Id, NumberOfApples = m.Child.NumberOfApples } }); ParentModel parentModel = query.Single(); Assert.That(parentModel.Id, Is.Not.Null); Assert.That(parentModel.Child.NumberOfApples, Is.GreaterThan(0)); transaction.Commit(); } }
public void Can_Read_Parent_Entity_Without_Child_IsNotNull_Extension() { Guid parentId; using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var parent = new TestEntityParent { Name = "Can_Read_Parent_Entity_Without_Child_IsNotNull_Extension", Description = "Desc: Can_Read_Parent_Entity_Without_Child_IsNotNull_Extension" }; session.Save(parent); transaction.Commit(); parentId = parent.Id; Assert.That(parent.Id, Is.Not.Null); } using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var query = session.Query <TestEntityParent>() .Where(x => x.Id == parentId) .Select(m => new ParentModel { Id = m.Id, Name = m.Name, Child = m.Child.IsNotNull() ? new ChildModel { Id = m.Child.Id, NumberOfApples = m.Child.NumberOfApples } : null }); ParentModel parentModel = query.Single(); Assert.That(parentModel.Id, Is.Not.Null); Assert.That(parentModel.Child, Is.Null); transaction.Commit(); } }
public void Can_Write_Parent_Entity_With_Child() { using (ISession session = SessionFactory.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { var parent = new TestEntityParent { Name = "Can_Write_Parent_Entity_With_Child", Description = "Desc: Can_Write_Parent_Entity_With_Child", Child = new TestEntityChild { Name = "Can_Write_Parent_Entity_With_Child - Child", Description = "Desc: Can_Write_Parent_Entity_With_Child - Child", NumberOfApples = 58256897 } }; session.Save(parent); transaction.Commit(); Assert.That(parent.Id, Is.Not.Null); } }