예제 #1
0
    internal bool ExtractLookupColumns(IDictionary <string, object> lookupColumns)
    {
        switch (_operator)
        {
        case ExpressionType.And:
            var ok = _left.ExtractLookupColumns(lookupColumns);
            if (ok)
            {
                ok = _right.ExtractLookupColumns(lookupColumns);
            }

            return(ok);

        case ExpressionType.Equal:
            var expr = IsValueConversion ? this : _left;
            while (expr.IsValueConversion)
            {
                expr = expr.Value as ODataExpression;
            }

            if (!string.IsNullOrEmpty(expr.Reference))
            {
                if (expr.Reference.IndexOfAny(_propertySeperator) >= 0)
                {
                    //skip child entity - may result in false positives
                    return(false);
                }

                var key = expr.Reference;
                if (key != null && !lookupColumns.ContainsKey(key))
                {
                    lookupColumns.Add(key, _right);
                }
            }

            return(true);

        default:
            if (IsValueConversion)
            {
                return((Value as ODataExpression).ExtractLookupColumns(lookupColumns));
            }
            else
            {
                return(false);
            }
        }
    }