示例#1
0
        private void HandleSelectManyCall(MethodCallExpression call)
        {
            //get the association path for the joined entity
            var collectionSelector = (LambdaExpression)LinqUtil.StripQuotes(call.Arguments[1]);

            LambdaExpression resultSelector = null;

            if (call.Arguments.Count == 3)
            {
                resultSelector = (LambdaExpression)LinqUtil.StripQuotes(call.Arguments[2]);
                string alias = resultSelector.Parameters[1].Name;

                var visitor = new SelectManyVisitor(rootCriteria, alias);
                visitor.Visit(collectionSelector.Body);
            }

            if (resultSelector != null)
            {
                //visit the result selector expression after the alias for the association has been created
                var resultSelectorVisitor = new SelectArgumentsVisitor(rootCriteria, session);
                resultSelectorVisitor.Visit(resultSelector.Body);

                rootCriteria.SetProjectionIfNotNull(resultSelectorVisitor.Projection);
                rootCriteria.SetResultTransformerIfNotNull(resultSelectorVisitor.Transformer);
            }
        }
        private void HandleSelectManyCall(MethodCallExpression call)
        {
            //get the association path for the joined entity
            var collectionSelector = (LambdaExpression)LinqUtil.StripQuotes(call.Arguments[1]);

            LambdaExpression resultSelector = null;
            if (call.Arguments.Count == 3)
            {
                resultSelector = (LambdaExpression)LinqUtil.StripQuotes(call.Arguments[2]);
                string alias = resultSelector.Parameters[1].Name;

                var visitor = new SelectManyVisitor(rootCriteria, alias);
                visitor.Visit(collectionSelector.Body);
            }

            if (resultSelector != null)
            {
                //visit the result selector expression after the alias for the association has been created
                var resultSelectorVisitor = new SelectArgumentsVisitor(rootCriteria, session);
                resultSelectorVisitor.Visit(resultSelector.Body);

                rootCriteria.SetProjectionIfNotNull(resultSelectorVisitor.Projection);
                rootCriteria.SetResultTransformerIfNotNull(resultSelectorVisitor.Transformer);
            }
        }