I have the following objects:
Parent
public virtual Guid Id { get; set; }
public virtual DateTime TimeStamp { get; set; }
public virtual IList<Child> Childs { get; set; }
Child
public virtual Guid Id { get; set; }
public virtual string Name { get; set; }
I use Fluent to Map One To Many as follows:
.Override<Parent>(obj =>obj.HasMany(x => x.Childs)
.Cascade.All()
.Not.Inverse()
.Not.KeyNullable()
.Not.KeyUpdate())
I need to get up to all Parent with Childs between dates order by TimeStamp.
I am trying to do it as follows (maxCapacity is int):
QueryOver<Parent>().Where(x => x.TimeStamp > from)
.And(x => x.TimeStamp < to).OrderBy(x => x.TimeStamp).Desc
.Left.JoinQueryOver<Child>(x => x.Childs)
.TransformUsing(new DistinctRootEntityResultTransformer())
.Take(maxCapacity).List();
The result is not what I expected since the Take(maxCapacity) is not on the parent result but on the total query result which includes parent and child.
How can I get the latest X already transformed Parent rows?
Thanks.