bdaniel7
unread,Apr 7, 2011, 4:24:08 PM4/7/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to nhusers
Hello,
I have this situation:
public class AnswerSet {
public virtual IList<Answer> Answers {set; get;}
}
session.CreateCriteria<AnswerSet>()
.CreateAlias( "Answers", "a" )
.SetProjection( Projections.ProjectionList()
.Add( Projections.GroupProperty( "TopicId" ), "TopicId" )
.Add( Projections.GroupProperty( "TopicName" ), "TopicName" )
.Add( Projections.SqlProjection( "count (case {a}.numerical_answer
when 1 then 1 when -1 then 1 else null end) as YesAnswers",
new[] { "YesAnswers" }, new IType[] { NHibernateUtil.Int32 } ),
"YesAnswers" )
How can I specify the child collection alias?
{a}.numerical_answer is not working.
The SQL equivalent is
select
[as].topic_id as TopicId
, [as].topic_name as TopicName
, count (case a.numerical_answer
when 1 then 1
when -1 then 1
else null
end) as YesAnswers
from answer_set [as] join answer a on a.answer_set_id = [as].id
Thank you,
Daniel