Represents determining if a given value matches any value in a sub query or a list.
Inheritance: DbExpression
Ejemplo n.º 1
0
        /// <summary>
        /// Translates the <paramref name="inExpression"/> into a string representation.
        /// </summary>
        /// <param name="inExpression">The <see cref="DbInExpression"/> to translate.</param>
        /// <returns><see cref="string"/></returns>
        protected override DbExpression VisitInExpression(DbInExpression inExpression)
        {
            string body = "{0} IN({1})";

            if (inExpression.Expression.ExpressionType == DbExpressionType.Query)
            {
                body = "{0} IN{1}";
            }
            string syntax = string.Format(body, Visit(inExpression.Target), Visit(inExpression.Expression));

            return(ExpressionFactory.Sql(syntax));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Translates the <paramref name="inExpression"/> into a string representation.
        /// </summary>
        /// <param name="inExpression">The <see cref="DbInExpression"/> to translate.</param>
        /// <returns><see cref="DbExpression"/></returns>
        protected virtual DbExpression VisitInExpression(DbInExpression inExpression)
        {
            var expression       = Visit(inExpression.Expression);
            var targetExpression = Visit(inExpression.Target);

            if (!ReferenceEquals(expression, inExpression.Expression) ||
                !ReferenceEquals(targetExpression, inExpression.Target))
            {
                return(ExpressionFactory.In(targetExpression, expression));
            }

            return(inExpression);
        }
 /// <summary>
 /// Creates a new <see cref="DbInExpression"/>.
 /// </summary>
 /// <param name="target">The target <see cref="DbExpression"/>.</param>
 /// <param name="expression">The <see cref="DbExpression"/> that represents a set of values or a sub query.</param>
 /// <returns>A <see cref="DbInExpression"/> instance.</returns>
 public DbInExpression In(DbExpression target, DbExpression expression)
 {
     var inExpression = new DbInExpression(target, expression);
     return inExpression;
 }
 /// <summary>
 /// Translates the <paramref name="inExpression"/> into a string representation.
 /// </summary>
 /// <param name="inExpression">The <see cref="DbInExpression"/> to translate.</param>
 /// <returns><see cref="string"/></returns>
 protected override DbExpression VisitInExpression(DbInExpression inExpression)
 {
     string body = "{0} IN({1})";
     if (inExpression.Expression.ExpressionType == DbExpressionType.Query || inExpression.Expression.ExpressionType == DbExpressionType.Select)
         body = "{0} IN{1}";
     string syntax = string.Format(body, Visit(inExpression.Target), Visit(inExpression.Expression));
     return ExpressionFactory.Sql(syntax);
 }
        /// <summary>
        /// Translates the <paramref name="inExpression"/> into a string representation.
        /// </summary>
        /// <param name="inExpression">The <see cref="DbInExpression"/> to translate.</param>
        /// <returns><see cref="DbExpression"/></returns>
        protected virtual DbExpression VisitInExpression(DbInExpression inExpression)
        {
            var expression = Visit(inExpression.Expression);
            var targetExpression = Visit(inExpression.Target);
            if (!ReferenceEquals(expression, inExpression.Expression) ||
                !ReferenceEquals(targetExpression, inExpression.Target))
            {
                return ExpressionFactory.In(targetExpression, expression);
            }

            return inExpression;
        }