Esempio n. 1
0
        protected override Expression VisitBinary(BinaryExpression b)
        {
            Visit(b.Left);
            var left = _state.ResultStack.Pop();

            Visit(b.Right);
            var right = _state.ResultStack.Pop();

            var dbOptr = _dbFactory.GetDbOperator(b.NodeType, b.Left.Type, b.Right.Type);

            if (left.IsNullVal() || right.IsNullVal())
            {
                dbOptr = dbOptr == DbOperator.Equal
                    ? DbOperator.Is
                    : dbOptr == DbOperator.NotEqual
                        ? DbOperator.IsNot
                        : dbOptr;
            }

            var dbBinary = _dbFactory.BuildBinary(left, dbOptr, right);

            if (dbOptr == DbOperator.Or)
            {
                var dbRefs = dbBinary.GetOperands().OfType <IDbSelectable>().Select(s => s.Ref);
                foreach (var dbRef in dbRefs)
                {
                    SqlTranslationHelper.UpdateJoinType(dbRef);
                }
            }

            _state.ResultStack.Push(dbBinary);
            return(b);
        }