Beispiel #1
0
        private static Expression HandleLast(
            EntityQueryModelVisitor entityQueryModelVisitor,
            ChoiceResultOperatorBase choiceResultOperator)
        {
            if (entityQueryModelVisitor.Expression is MethodCallExpression methodCallExpression &&
                methodCallExpression.Method
                .MethodIsClosedFormOf(entityQueryModelVisitor.LinqOperatorProvider.Select))
            {
                // Push Last down below Select

                return
                    (methodCallExpression.Update(
                         methodCallExpression.Object,
                         new[]
                {
                    Expression.Call(
                        entityQueryModelVisitor.LinqOperatorProvider.ToSequence
                        .MakeGenericMethod(methodCallExpression.Arguments[0].Type.GetSequenceType()),
                        CallWithPossibleCancellationToken(
                            (choiceResultOperator.ReturnDefaultWhenEmpty
                                        ? entityQueryModelVisitor.LinqOperatorProvider.LastOrDefault
                                        : entityQueryModelVisitor.LinqOperatorProvider.Last)
                            .MakeGenericMethod(methodCallExpression.Arguments[0].Type.GetSequenceType()),
                            methodCallExpression.Arguments[0])),
                    methodCallExpression.Arguments[1]
                }));
            }

            return(CallWithPossibleCancellationToken(
                       (choiceResultOperator.ReturnDefaultWhenEmpty
                    ? entityQueryModelVisitor.LinqOperatorProvider.LastOrDefault
                    : entityQueryModelVisitor.LinqOperatorProvider.Last)
                       .MakeGenericMethod(entityQueryModelVisitor.Expression.Type.GetSequenceType()),
                       entityQueryModelVisitor.Expression));
        }
Beispiel #2
0
 private static Expression HandleSingle(
     EntityQueryModelVisitor entityQueryModelVisitor, ChoiceResultOperatorBase choiceResultOperator)
 => CallWithPossibleCancellationToken(
     (choiceResultOperator.ReturnDefaultWhenEmpty
             ? entityQueryModelVisitor.LinqOperatorProvider.SingleOrDefault
             : entityQueryModelVisitor.LinqOperatorProvider.Single)
     .MakeGenericMethod(entityQueryModelVisitor.Expression.Type.GetSequenceType()),
     entityQueryModelVisitor.Expression);
Beispiel #3
0
 private static Expression HandleLast(
     EntityQueryModelVisitor entityQueryModelVisitor, ChoiceResultOperatorBase choiceResultOperator)
 => CallWithPossibleCancellationToken(
     (choiceResultOperator.ReturnDefaultWhenEmpty
             ? entityQueryModelVisitor.LinqOperatorProvider.LastOrDefault
             : entityQueryModelVisitor.LinqOperatorProvider.Last)
     .MakeGenericMethod(entityQueryModelVisitor.StreamedSequenceInfo.ResultItemType),
     entityQueryModelVisitor.Expression);
 private static Expression HandleLast(
     EntityQueryModelVisitor entityQueryModelVisitor, ChoiceResultOperatorBase choiceResultOperator)
 {
     return(Expression.Call(
                (choiceResultOperator.ReturnDefaultWhenEmpty
             ? _lastOrDefault
             : _last).MakeGenericMethod(entityQueryModelVisitor.StreamedSequenceInfo.ResultItemType),
                entityQueryModelVisitor.Expression));
 }