예제 #1
0
        public virtual void SetProjectionCountExpression([NotNull] CountExpression countExpression)
        {
            Check.NotNull(countExpression, "countExpression");

            PushDownIfLimit();
            PushDownIfDistinct();

            ClearProjection();

            _projectionExpression = countExpression;
        }
        public override Expression VisitCountExpression(CountExpression countExpression)
        {
            Check.NotNull(countExpression, nameof(countExpression));

            if (countExpression.Type == typeof(long))
            {
                Sql.Append("COUNT_BIG(*)");
                return countExpression;
            }

            return base.VisitCountExpression(countExpression);
        }
예제 #3
0
        public override Expression VisitCountExpression(CountExpression countExpression)
        {
            Check.NotNull(countExpression, nameof(countExpression));

            // Note that PostgreSQL COUNT(*) is BIGINT (64-bit). For 32-bit Count() expressions we cast.
            if (countExpression.Type == typeof(long))
            {
                Sql.Append("COUNT(*)");
            }
            else if (countExpression.Type == typeof(int))
            {
                Sql.Append("COUNT(*)::INT4");
            }
            else throw new NotSupportedException(string.Format("Count expression with type {0} not supported", countExpression.Type));

            return countExpression;
        }