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

Daniel Marbach November 12, 2012 at 9:45 PM
Man, it's 10 months ago Used nuget to get other dependencies such as SqlCompact... And I wanted a repro solution which reflects the problem we saw.

Oskar Berggren November 12, 2012 at 9:40 PM
It is heavy on the "full"
I don't quite understand it... The idea is to inherit from BugTestCase so that you don't need all that setup code in the issue specific test fixture. And why the nuget? The NHibernate assembly and related stuff is already available in the lib folder. So is there something important about this, or just and oversight?
/Oskar

Daniel Marbach November 12, 2012 at 9:24 PM
I don’t know what you want more. Under:
https://github.com/danielmarbach/nhibernate-core-testcase/tree/sqlce-querying
is a full repro solution
Daniel

Daniel Marbach November 12, 2012 at 9:24 PM
I don’t know what you want more. Under:
https://github.com/danielmarbach/nhibernate-core-testcase/tree/sqlce-querying
is a full repro solution
Daniel
From: Oskar Berggren (JIRA) jira@nhibernate.jira.com
Sent: Montag, 12. November 2012 22:17
To: daniel.marbach@openplace.net
Subject: [JIRA] (NH-3028) QueryOver with constants does only execute projections at the beginning of the select
<https://nhibernate.jira.com/s/en_USwq7kxo-418945332/812/55/_/jira-logo-scaled.png>
<https://nhibernate.jira.com/secure/useravatar?avatarId=10152> <https://nhibernate.jira.com/secure/ViewProfile.jspa?name=oskar.berggren> Oskar Berggren commented on Bug <https://nhibernate.jira.com/images/icons/bug.gif> <https://nhibernate.jira.com/browse/NH-3028>
<https://nhibernate.jira.com/browse/NH-3028> QueryOver with constants does only execute projections at the beginning of the select
How does it fail? Could you create a minimal test case that illustrates the issue, as a pull request on github, please?
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: <http://www.atlassian.com/software/jira> http://www.atlassian.com/software/jira

Oskar Berggren November 12, 2012 at 9:16 PM
How does it fail? Could you create a minimal test case that illustrates the issue, as a pull request on github, please?
Details
Details
Assignee
Reporter

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>();