コード例 #1
0
        private void HandleKnownTypeProject(NewExpression newExpr)
        {
            NHibernate.Transform.AliasToBeanConstructorResultTransformer transformer = new NHibernate.Transform.AliasToBeanConstructorResultTransformer(newExpr.Constructor);

            NHibernate.Expression.ProjectionList projections = NHibernate.Expression.Projections.ProjectionList();
            foreach (MemberExpression member in newExpr.Arguments)
            {
                projections.Add(NHibernate.Expression.Projections.Property(member.Member.Name));
            }
            rootCriteria.SetProjection(projections);
            rootCriteria.SetResultTransformer(transformer);
        }
コード例 #2
0
        private void HandleAnonymousProjectionOfType(MemberInitExpression mie)
        {
            LinqProjectionResultTransformer transformer = new LinqProjectionResultTransformer(mie.NewExpression.Type,
                                                                                              mie.Bindings.ToArray());

            NHibernate.Expression.ProjectionList projections = NHibernate.Expression.Projections.ProjectionList();
            foreach (MemberBinding binding in mie.Bindings)
            {
                projections.Add(NHibernate.Expression.Projections.Property(binding.Member.Name));
            }
            rootCriteria.SetProjection(projections);
            rootCriteria.SetResultTransformer(transformer);
        }