Parent has one to many public virtual IList<Child> Children { get; set; }
Child has a one Parent property.
Code:
//In Parent Map
HasMany<Child>(x => x.Children)
.Not.KeyNullable()
.Inverse()
.AsBag()
.KeyColumns.Add("ParentId")
;
//In Child Map
References<Parent>(x => x.Parent)
.ForeignKey()
.Columns("ParentId")
.Not.Nullable()
.LazyLoad()
;
//Query that falls over
Child childAlias = null;
var myQuery = session.QueryOver<Parent>(() => parentAlias)
.Inner.JoinAlias(x => x.Child, () => childAlias)
.Where(() => childAlias.Parent.Id == 1)
.SelectList(list => list
.Select(x => x.Id).WithAlias(() => dmprd.ParentId)
.Select(x => x.Child).WithAlias(() => dmprd.Children))
.TransformUsing(Transformers.AliasToBean<SomeTarget>())
.List<SomeTarget>();
.Select(x => x.Child).WithAlias causes an exception out of bounds error.
{"Index was outside the bounds of the array."}
Cant see it for the life of me why the child list is failing, the sql works if I paste into SQL Server query and return say Child.Id field.
Any ideas gratefully received.