diff --git a/src/NHibernate.Test/Async/NHSpecificTest/GH1583/Fixture.cs b/src/NHibernate.Test/Async/NHSpecificTest/GH1583/Fixture.cs new file mode 100644 index 00000000000..96fb1280d1d --- /dev/null +++ b/src/NHibernate.Test/Async/NHSpecificTest/GH1583/Fixture.cs @@ -0,0 +1,70 @@ +//------------------------------------------------------------------------------ +// +// 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.Collections.Generic; +using System.Linq; +using NHibernate.Cfg.MappingSchema; +using NHibernate.Mapping.ByCode; +using NUnit.Framework; +using NHibernate.Linq; + +namespace NHibernate.Test.NHSpecificTest.GH1583 +{ + using System.Threading.Tasks; + + [TestFixture] + public class FixtureAsync : TestCaseMappingByCode + { + protected override HbmMapping GetMappings() + { + var mapper = new ModelMapper(); + mapper.Class(rc => + { + rc.Id(x => x.ParentId, m => m.Generator(Generators.HighLow)); + rc.List( + x => x.Children, + listMap => + { + listMap.Table("Children"); + listMap.Index(index => index.Column("SortIndex")); + + listMap.Key(keyMap => + { + keyMap.Column(clm => + { + clm.Name("ParentId"); + }); + }); + listMap.Lazy(CollectionLazy.Lazy); + listMap.Cascade(Mapping.ByCode.Cascade.All | Mapping.ByCode.Cascade.All); + listMap.Inverse(true); + }, + rel => { rel.Component(cmp => { cmp.Parent(x => x.ParentLink); }); } + ); + }); + + return mapper.CompileMappingForAllExplicitlyAddedEntities(); + } + + [Test] + [KnownBug("GH-1583")] + public async Task QueryForPropertyOfParentInComponentAsync() + { + using (var session = OpenSession()) + using (session.BeginTransaction()) + { + var result = await ((from p in session.Query().SelectMany(x => x.Children) + select p.ParentLink.ParentId).ToListAsync()); + + Assert.That(result, Is.Empty); + } + } + } +} diff --git a/src/NHibernate.Test/NHSpecificTest/GH1583/Fixture.cs b/src/NHibernate.Test/NHSpecificTest/GH1583/Fixture.cs new file mode 100644 index 00000000000..92685179af7 --- /dev/null +++ b/src/NHibernate.Test/NHSpecificTest/GH1583/Fixture.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using System.Linq; +using NHibernate.Cfg.MappingSchema; +using NHibernate.Mapping.ByCode; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.GH1583 +{ + public class Parent + { + public virtual int ParentId { get; set; } + public virtual IList Children { get; set; } + } + + public class Child + { + public virtual Parent ParentLink { get; set; } + } + + [TestFixture] + public class Fixture : TestCaseMappingByCode + { + protected override HbmMapping GetMappings() + { + var mapper = new ModelMapper(); + mapper.Class(rc => + { + rc.Id(x => x.ParentId, m => m.Generator(Generators.HighLow)); + rc.List( + x => x.Children, + listMap => + { + listMap.Table("Children"); + listMap.Index(index => index.Column("SortIndex")); + + listMap.Key(keyMap => + { + keyMap.Column(clm => + { + clm.Name("ParentId"); + }); + }); + listMap.Lazy(CollectionLazy.Lazy); + listMap.Cascade(Mapping.ByCode.Cascade.All | Mapping.ByCode.Cascade.All); + listMap.Inverse(true); + }, + rel => { rel.Component(cmp => { cmp.Parent(x => x.ParentLink); }); } + ); + }); + + return mapper.CompileMappingForAllExplicitlyAddedEntities(); + } + + [Test] + [KnownBug("GH-1583")] + public void QueryForPropertyOfParentInComponent() + { + using (var session = OpenSession()) + using (session.BeginTransaction()) + { + var result = (from p in session.Query().SelectMany(x => x.Children) + select p.ParentLink.ParentId).ToList(); + + Assert.That(result, Is.Empty); + } + } + } +}