Esempio n. 1
0
        private string FormatInQuery(string exp, object[] array, SubqueryParts query)
        {
            if (array.Length == 0)
            {
                return("false");
            }
            if (array.Length == 1 && array[0] == null)
            {
                return(exp + " IS NULL ");
            }

            var qsre = query.Selector as QuerySourceReferenceExpression;

            if (qsre != null && qsre.ReferencedQuerySource.Equals(query.MainFrom) &&
                NpgsqlTypes.TypeConverter.CanConvert(query.MainFrom.ItemType))
            {
                //TODO: values
                return(array.Length == 1
                                        ? exp + " = " + NpgsqlTypes.TypeConverter.Convert(query.MainFrom.ItemType, array[0])
                                        : exp + " IN ("
                       + string.Join(
                           ",",
                           array.Select(it => NpgsqlTypes.TypeConverter.Convert(query.MainFrom.ItemType, it)))
                       + ")");
            }

            return(exp + " IN (SELECT " + query.GetSqlExpression(query.Selector)
                   + " FROM unnest(" + query.FormatArray(array) + ") \"" + query.MainFrom.ItemName + "\")");
        }
 protected override Expression VisitConditionalExpression(ConditionalExpression expression)
 {
     if (!Query.CanQueryInMemory)
     {
         var caseWhen = Query.GetSqlExpression(expression);
         Query.AddSelectPart(null, caseWhen, null, expression.Type, null);
     }
     return(expression);
 }
Esempio n. 3
0
 protected override Expression VisitConditionalExpression(ConditionalExpression expression)
 {
     if (!Query.CanQueryInMemory)
     {
         var ctx      = new QueryContext(true, false, false);           // Query.Context.Select();
         var caseWhen = Query.GetSqlExpression(expression, string.Empty, ctx);
         Query.AddSelectPart(null, caseWhen, null, expression.Type, null);
     }
     return(expression);
 }