Skip to content

Test Parent property is not accessible in queries #1584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions src/NHibernate.Test/Async/NHSpecificTest/GH1583/Fixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by AsyncGenerator.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------


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<Parent>(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<Parent>().SelectMany(x => x.Children)
select p.ParentLink.ParentId).ToListAsync());

Assert.That(result, Is.Empty);
}
}
}
}
68 changes: 68 additions & 0 deletions src/NHibernate.Test/NHSpecificTest/GH1583/Fixture.cs
Original file line number Diff line number Diff line change
@@ -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<Child> 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<Parent>(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<Parent>().SelectMany(x => x.Children)
select p.ParentLink.ParentId).ToList();

Assert.That(result, Is.Empty);
}
}
}
}