internal static IEnumerable <DbExpression> FlattenAssociativeExpression(DbExpressionKind expressionKind, params DbExpression[] arguments)
        {
            if (!CommandTreeUtils._associativeExpressionKinds.Contains(expressionKind))
            {
                return((IEnumerable <DbExpression>)arguments);
            }
            List <DbExpression> argumentList = new List <DbExpression>();

            foreach (DbExpression expression in arguments)
            {
                CommandTreeUtils.ExtractAssociativeArguments(expressionKind, argumentList, expression);
            }
            return((IEnumerable <DbExpression>)argumentList);
        }
 private static void ExtractAssociativeArguments(DbExpressionKind expressionKind, List <DbExpression> argumentList, DbExpression expression)
 {
     if (expression.ExpressionKind != expressionKind)
     {
         argumentList.Add(expression);
     }
     else
     {
         DbBinaryExpression binaryExpression = expression as DbBinaryExpression;
         if (binaryExpression != null)
         {
             CommandTreeUtils.ExtractAssociativeArguments(expressionKind, argumentList, binaryExpression.Left);
             CommandTreeUtils.ExtractAssociativeArguments(expressionKind, argumentList, binaryExpression.Right);
         }
         else
         {
             DbArithmeticExpression arithmeticExpression = (DbArithmeticExpression)expression;
             CommandTreeUtils.ExtractAssociativeArguments(expressionKind, argumentList, arithmeticExpression.Arguments[0]);
             CommandTreeUtils.ExtractAssociativeArguments(expressionKind, argumentList, arithmeticExpression.Arguments[1]);
         }
     }
 }