NHibernate分组和两个条件和的除法

时间:2015-06-30 09:24:13

标签: nhibernate queryover

我有以下代码:

var classAttendanceDetails =
                        Session.QueryOver<StudentClassAttendanceDetails>(() => scadAlias)
                            .JoinAlias(() => scadAlias.StudentClassAttendence, () => scaAlias)
                            .JoinAlias(() => scaAlias.Lecture, () => lAlias).JoinAlias(() => scaAlias.Teacher, () => tAlias).JoinAlias(() => scadAlias.StudentProgram, () => spAlias);
    var queryover = classAttendanceDetails
                        .Select(
                            Projections.Group<StudentClassAttendanceDetails>(c => scaAlias.Lecture),
                            Projections.Group<StudentClassAttendanceDetails>(c => scaAlias.Teacher),
                            Projections.Sum(
                                Projections.Conditional(
                                    Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback == 1),
                                    Projections.Constant(1),
                                    Projections.Constant(0))),
                            Projections.Sum(
                                Projections.Conditional(
                                    Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback == 2),
                                    Projections.Constant(1),
                                    Projections.Constant(0))),
                            Projections.Sum(
                                Projections.Conditional(
                                    Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback == 3),
                                    Projections.Constant(1),
                                    Projections.Constant(0))),
                            Projections.Sum(
                                Projections.Conditional(
                                    Restrictions.Where<StudentClassAttendanceDetails>(
                                        f => f.StudentFeedback.IsIn(new[] {1, 2, 3})),
                                    Projections.Constant(1),
                                    Projections.Constant(0))),
                                    Projections.SqlFunction(
                    new VarArgsSQLFunction("(", "/", ")"),
                    NHibernateUtil.Int32,
                    Projections.Sum(
                Projections.Conditional(
                    Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback == 1),
                    Projections.Constant(1),
                    Projections.Constant(0))),
                    Projections.Conditional(
                    Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback.IsIn(new[] { 1, 2, 3 })),
                    Projections.Constant(1),
                    Projections.Constant(0)))
                                    ).OrderBy(Projections.SqlFunction(
            new VarArgsSQLFunction("(", "/", ")"),
            NHibernateUtil.Int32,
            Projections.Sum(
        Projections.Conditional(
            Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback == 1),
            Projections.Constant(1),
            Projections.Constant(0))),
            Projections.Conditional(
            Restrictions.Where<StudentClassAttendanceDetails>(f => f.StudentFeedback.IsIn(new[] { 1, 2, 3 })),
            Projections.Constant(1),
            Projections.Constant(0)))).Desc;

在这里,我试图按结果数量排序结果,其中反馈是1,由反馈为1/2 / 3的结果没有划分。但我不能按此排序,因为它不包含在组中。我如何将其包含在

组中

0 个答案:

没有答案