QueryOver with constants does only execute projections at the beginning of the select

Description

The following query works:

session.QueryOver(() => orderAlias)
.Where(o => o.Id == this.orderId)
.Select(
Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools),
Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
Projections.Property(() => orderAlias.Description).WithAlias(() => orderDetailAlias.Description),
Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate)
)
.TransformUsing(Transformers.AliasToBean<OrderDetailData>())
.SingleOrDefault<OrderDetailData>();

The following identical query does not work:

session.QueryOver(() => orderAlias)
.Where(o => o.Id == this.orderId)
.Select(
Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
Projections.Property(() => orderAlias.Description).WithAlias(() => orderDetailAlias.Description),
Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate),
Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools)
)
.TransformUsing(Transformers.AliasToBean<OrderDetailData>())
.SingleOrDefault<OrderDetailData>();

You can get it working if you randomly insert a constant projection before the other constants like:

session.QueryOver(() => orderAlias)
.Where(o => o.Id == this.orderId)
.Select(
Projections.Property(() => orderAlias.Id).WithAlias(() => orderDetailAlias.Id),
Projections.Property(() => orderAlias.Name).WithAlias(() => orderDetailAlias.Name),
Projections.Constant("Foooo").WithAlias(() => orderDetailAlias.Description),
Projections.Property(() => orderAlias.CreatedBy).WithAlias(() => orderDetailAlias.CreatedBy),
Projections.Property(() => orderAlias.CreationDate).WithAlias(() => orderDetailAlias.CreationDate),
Projections.Property(() => orderAlias.PlannedDeliveryDate).WithAlias(() => orderDetailAlias.PlannedDeliveryDate),
Projections.Constant(workpieceCount).WithAlias(() => orderDetailAlias.NumberOfWorkpieces),
Projections.Constant(toolCount).WithAlias(() => orderDetailAlias.NumberOfTools)
)
.TransformUsing(Transformers.AliasToBean<OrderDetailData>())
.SingleOrDefault<OrderDetailData>();

Environment

None

Assignee

Unassigned

Reporter

Daniel Marbach

Labels

Components

Affects versions

Priority

Critical
Configure