diff --git a/src/NHibernate.Test/Async/NHSpecificTest/GH3569/ManyToOneFixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/GH3569/ManyToOneFixture.cs new file mode 100644 index 0000000000..76e1660ab8 --- /dev/null +++ b/src/NHibernate.Test/Async/NHSpecificTest/GH3569/ManyToOneFixture.cs @@ -0,0 +1,59 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by AsyncGenerator. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using NUnit.Framework; + +/* 项目“NHibernate.Test (net48)”的未合并的更改 +在此之前: +using NHibernate.Test.NHSpecificTest; +在此之后: +using NHibernate.Test.NHSpecificTest; +using NHibernate; +using NHibernate.Test; +using NHibernate.Test.MappingTest; +using NHibernate.Test.NHSpecificTest.GH3569; +*/ +using NHibernate.Test.NHSpecificTest; + +namespace NHibernate.Test.NHSpecificTest.GH3569 +{ + + + + + + + + [TestFixture] + internal class ManyToOneFixtureAsync : BugTestCase + { + [Test] + public async Task AccessIdOfManyToOneInEmbeddableAsync() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + Parent p = new Parent(); + p.ContainedChildren.Add(new ContainedChild(new Child())); + await (s.PersistAsync(p)); + await (t.CommitAsync()); + var list = await (s.CreateQuery("from Parent p join p.ContainedChildren c where c.Child.Id is not null").ListAsync()); + Assert.AreNotEqual(0, list.Count); + await (s.DeleteAsync(p)); + await (t.CommitAsync()); + s.Close(); + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/GH3569/Child.cs b/src/NHibernate.Test/NHSpecificTest/GH3569/Child.cs new file mode 100644 index 0000000000..def90de9af --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH3569/Child.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NHibernate.Test.NHSpecificTest.GH3569 +{ + public class Child + { + private int id; + public virtual int Id + { + get { return id; } + set { id = value; } + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/GH3569/ContainedChild.cs b/src/NHibernate.Test/NHSpecificTest/GH3569/ContainedChild.cs new file mode 100644 index 0000000000..03ac0be8dc --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH3569/ContainedChild.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using NHibernate.UserTypes; + +namespace NHibernate.Test.NHSpecificTest.GH3569 +{ + public class ContainedChild + { + private int id; + public virtual int Id + { + get { return id; } + set { id = value; } + } + private Child child; + + public ContainedChild() + { + } + + public ContainedChild(Child child) + { + this.child = child; + } + + public virtual Child Child + { + get { return child; } + set { child = value; } + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/GH3569/ManyToOneFixture.cs b/src/NHibernate.Test/NHSpecificTest/GH3569/ManyToOneFixture.cs new file mode 100644 index 0000000000..f71c08f329 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH3569/ManyToOneFixture.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using NUnit.Framework; + +/* 项目“NHibernate.Test (net48)”的未合并的更改 +在此之前: +using NHibernate.Test.NHSpecificTest; +在此之后: +using NHibernate.Test.NHSpecificTest; +using NHibernate; +using NHibernate.Test; +using NHibernate.Test.MappingTest; +using NHibernate.Test.NHSpecificTest.GH3569; +*/ +using NHibernate.Test.NHSpecificTest; + +namespace NHibernate.Test.NHSpecificTest.GH3569 +{ + + + + + + + + [TestFixture] + internal class ManyToOneFixture : BugTestCase + { + [Test] + public void AccessIdOfManyToOneInEmbeddable() + { + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + Parent p = new Parent(); + p.ContainedChildren.Add(new ContainedChild(new Child())); + s.Persist(p); + t.Commit(); + var list = s.CreateQuery("from Parent p join p.ContainedChildren c where c.Child.Id is not null").List(); + Assert.AreNotEqual(0, list.Count); + s.Delete(p); + t.Commit(); + s.Close(); + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/GH3569/Mappings.hbm.xml b/src/NHibernate.Test/NHSpecificTest/GH3569/Mappings.hbm.xml new file mode 100644 index 0000000000..78099ac198 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH3569/Mappings.hbm.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/NHibernate.Test/NHSpecificTest/GH3569/Parent.cs b/src/NHibernate.Test/NHSpecificTest/GH3569/Parent.cs new file mode 100644 index 0000000000..3504b1746b --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH3569/Parent.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NHibernate.Test.NHSpecificTest.GH3569 +{ + public class Parent + { + private int id; + private ContainedChild containedChild; + private ISet containedChildren = new HashSet(); + + public virtual int Id + { + get { return id; } + set { id = value; } + } + + public virtual ContainedChild ContainedChild + { + get { return containedChild; } + set { containedChild = value; } + } + public virtual ISet ContainedChildren + { + get { return containedChildren; } + set { containedChildren = value; } + } + } +}