sdk/dotnet/src/Microsoft.Datasync.Client/Query/Linq/FilterBuildingExpressionVisitor.cs
/// <summary>
/// Checks if the provided binary expression is an enum.
/// </summary>
/// <param name="node">The binary expression to check</param>
/// <param name="unaryExpression">The expression which is the enum.</param>
/// <param name="constantExpression">The constant expression containing the enum value</param>
/// <returns>Trye if an enum expression is found.</returns>
Checks if the provided binary expression is an enum.
Checks if the provided binary expression is an enum .
internal static bool IsEnumExpression(BinaryExpression node, out UnaryExpression unaryExpression, out ConstantExpression constantExpression)
        {
            if (node.Left is UnaryExpression left && IsEnumExpression(left) && node.Right is ConstantExpression leftExpr)
            {
                unaryExpression = left;
                constantExpression = leftExpr;
                return true;
            }
            if (node.Right is UnaryExpression right && IsEnumExpression(right) && node.Left is ConstantExpression rightExpr)
            {
                unaryExpression = right;
                constantExpression = rightExpr;
                return true;
            }
            unaryExpression = null;
            constantExpression = null;
            return false;
        }
internal static bool IsEnumExpression ( BinaryExpression node , out UnaryExpression unaryExpression , out ConstantExpression constantExpression ) { if ( node . Left is UnaryExpression left && IsEnumExpression ( left ) && node . Right is ConstantExpression leftExpr ) { unaryExpression = left ; constantExpression = leftExpr ; return true ; } if ( node . Right is UnaryExpression right && IsEnumExpression ( right ) && node . Left is ConstantExpression rightExpr ) { unaryExpression = right ; constantExpression = rightExpr ; return true ; } unaryExpression = null ; constantExpression = null ; return false ; }
Checks if the provided binary expression is an enum.
Checks if the provided binary expression is an enum .
// Case 1: enum on the left side // Case 2: enum on the right side
Trye if an enum expression is found.
Trye if an enum expression is found .
node
BinaryExpression
The binary expression to check
The binary expression to check
UnaryExpression
out
ConstantExpression
out
unaryExpression
The expression which is the enum.
The expression which is the enum .
constantExpression
The constant expression containing the enum value
The constant expression containing the enum value