Пример #1
0
 private SqlExpression ApplyTypeMappingOnSqlConditional(
     SqlConditionalExpression sqlConditionalExpression,
     CoreTypeMapping?typeMapping)
 => sqlConditionalExpression.Update(
     sqlConditionalExpression.Test,
     ApplyTypeMapping(sqlConditionalExpression.IfTrue, typeMapping),
     ApplyTypeMapping(sqlConditionalExpression.IfFalse, typeMapping));
        public override SqlExpression VisitSimpleCaseExpression(PlSqlParser.SimpleCaseExpressionContext context)
        {
            var exp = Visit(context.atom());

            var switches = new List <CaseSwitch>();

            foreach (var partContext in context.simpleCaseWhenExpressionPart())
            {
                var otherExp = Visit(partContext.conditionWrapper());
                switches.Add(new CaseSwitch {
                    Condition        = SqlExpression.Equal(exp, otherExp),
                    ReturnExpression = Visit(partContext.expressionWrapper())
                });
            }

            if (context.caseElseExpressionPart() != null)
            {
                var returnExp = Visit(context.caseElseExpressionPart().expressionWrapper());
                switches.Add(new CaseSwitch {
                    Condition        = SqlExpression.Constant(true),
                    ReturnExpression = returnExp
                });
            }

            SqlConditionalExpression conditional = null;

            for (int i = switches.Count - 1; i >= 0; i--)
            {
                var current = switches[i];

                var condition = SqlExpression.Conditional(current.Condition, current.ReturnExpression);

                if (conditional != null)
                {
                    conditional = SqlExpression.Conditional(current.Condition, current.ReturnExpression, conditional);
                }
                else
                {
                    conditional = condition;
                }
            }

            return(conditional);
        }
Пример #3
0
 /// <summary>
 ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
 ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
 ///     any release. You should only use it directly in your code with extreme caution and knowing that
 ///     doing so can result in application failures when updating to a new Entity Framework Core release.
 /// </summary>
 protected abstract Expression VisitSqlConditional(SqlConditionalExpression sqlConditionalExpression);