Sly
2018-02-21 17:06:46 UTC
This test case is failing, but I'm not sure if I'm not doing something
wrong in here:
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("Position"));
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]
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);
}
}
}
Its currently failing with exception NHibernate.QueryException : could not
resolve property: ParentLink of: component[].
wrong in here:
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("Position"));
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]
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);
}
}
}
Its currently failing with exception NHibernate.QueryException : could not
resolve property: ParentLink of: component[].
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at https://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.