Example #1
0
        // PostgreSQL COUNT() always returns bigint, so we need to downcast to int
        public override SqlExpression TranslateCount(SqlExpression sqlExpression)
        {
            Check.NotNull(sqlExpression, nameof(sqlExpression));

            return(_sqlExpressionFactory.Convert(
                       _sqlExpressionFactory.ApplyDefaultTypeMapping(
                           _sqlExpressionFactory.Function(
                               "COUNT",
                               new[] { sqlExpression },
                               nullable: false,
                               argumentsPropagateNullability: FalseArrays[1],
                               typeof(long))),
                       typeof(int), _typeMappingSource.FindMapping(typeof(int))));
        }
Example #2
0
        // PostgreSQL COUNT() always returns bigint, so we need to downcast to int
        // TODO: Translate Count with predicate for GroupBy (see base implementation)
        public override SqlExpression TranslateCount(Expression expression = null)
        {
            if (expression != null)
            {
                // TODO: Translate Count with predicate for GroupBy
                return(null);
            }

            return(_sqlExpressionFactory.Convert(
                       _sqlExpressionFactory.ApplyDefaultTypeMapping(
                           _sqlExpressionFactory.Function("COUNT", new[] { _sqlExpressionFactory.Fragment("*") }, typeof(long))),
                       typeof(int), _sqlExpressionFactory.FindMapping(typeof(int))));
        }
Example #3
0
 // PostgreSQL COUNT() always returns bigint, so we need to downcast to int
 // TODO: Translate Count with predicate for GroupBy (see base implementation)
 public override SqlExpression TranslateCount(Expression expression = null)
 => _sqlExpressionFactory.Convert(
     _sqlExpressionFactory.ApplyDefaultTypeMapping(
         _sqlExpressionFactory.Function("COUNT", new[] { _sqlExpressionFactory.Fragment("*") }, typeof(long))),
     typeof(int), _sqlExpressionFactory.FindMapping(typeof(int)));