Ability to add projection on entity.

Description

This functionality is needed in order to support many scenarios in NHibernate.Linq. This feature is directly related with Subquery Projection.

One example use can be:

rootCriteria.SetProjection(Projections.ProjectionList()
.Add(Projections.Entity("c"))
.Add(Projections.Alias(Projections.SubQuery(visitor.Criteria), "orderby"));

One concrete example of where this is necessary is the following linq query:

from c in customer
orderby c.Orders.Count
select c;

which should roughly translate to the following SQL query:

select
c.*,
(select count from Orders e where e.CustomerID = c.CustomerID) orderby
from Customers c
order by orderby

Priority set to major in order to support nhibernate features

Environment

None

Activity

Show:

Mihai Codrean 
November 2, 2009 at 7:40 AM

What is the issue number that this duplicated?

Tuna Toksoz 
October 5, 2008 at 6:19 AM

points to the same issue

Tuna Toksoz 
July 18, 2008 at 2:12 PM

Don't know actually. Going for the hardcoding, i mean getting properties from the metadata and appending them to sqlstring would be painful.
More pain would come when nested queries are used(subquery in from clause, for example).
This is of high importance for linq to nhibernate, though.

OrenE 
July 18, 2008 at 12:48 AM

Projections.Entity is an interesting problem, not sure how to solve this.

Remco Ros 
July 5, 2008 at 8:28 AM

This feature is directly related with Subquery Projection. (https://nhibernate.jira.com/browse/NH-1359)

Duplicate

Details

Assignee

Reporter

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created July 4, 2008 at 1:06 PM
Updated April 1, 2013 at 7:01 PM
Resolved October 5, 2008 at 6:19 AM
Who's Looking?