src/Shared/EntityFramework/Core/Objects/ELinq/ReflectionUtil.cs
// <summary>
// Identifies method call expressions as calls to known sequence operators.
// </summary>
// <param name="expression"> Expression that may represent a call to a known sequence method </param>
// <param name="unwrapLambda">
// If <c>true</c> , and the <paramref name="expression" /> argument is a LambdaExpression, the Body of the LambdaExpression argument will be retrieved, and that expression will then be examined for a sequence method call instead of the Lambda itself.
// </param>
// <param name="sequenceMethod"> Identified sequence operator </param>
// <returns>
// <c>true</c> if <paramref name="expression" /> is a <see cref="MethodCallExpression" /> and its target method is known; <c>false</c> otherwise
// </returns>
Identifies method call expressions as calls to known sequence operators.
Identifies method call expressions as calls to known sequence operators .
internal static bool TryIdentifySequenceMethod(Expression expression, bool unwrapLambda, out SequenceMethod sequenceMethod)
        {
            if (expression.NodeType == ExpressionType.Lambda && unwrapLambda)
            {
                expression = ((LambdaExpression)expression).Body;
            }
            if (expression.NodeType
                == ExpressionType.Call)
            {
                var methodCall = (MethodCallExpression)expression;
                return TryIdentifySequenceMethod(methodCall.Method, out sequenceMethod);
            }
            sequenceMethod = default(SequenceMethod);
            return false;
        }
internal static bool TryIdentifySequenceMethod ( Expression expression , bool unwrapLambda , out SequenceMethod sequenceMethod ) { if ( expression . NodeType == ExpressionType . Lambda && unwrapLambda ) { expression = ( ( LambdaExpression ) expression ) . Body ; } if ( expression . NodeType == ExpressionType . Call ) { var methodCall = ( MethodCallExpression ) expression ; return TryIdentifySequenceMethod ( methodCall . Method , out sequenceMethod ) ; } sequenceMethod = default ( SequenceMethod ) ; return false ; }
Identifies method call expressions as calls to known sequence operators.
Identifies method call expressions as calls to known sequence operators .
true is a  and its target method is known; false
true is a and its target method is known ; false
expression
Expression
Expression that may represent a call to a known sequence method
Expression that may represent a call to a known sequence method
unwrapLambda
bool
If true argument is a LambdaExpression, the Body of the LambdaExpression argument will be retrieved, and that expression will then be examined for a sequence method call instead of the Lambda itself.
If true argument is a LambdaExpression the Body of the LambdaExpression argument will be retrieved and that expression will then be examined for a sequence method call instead of the Lambda itself .
SequenceMethod
out
sequenceMethod
Identified sequence operator
Identified sequence operator