Revenj.DatabasePersistence.Postgres.QueryGeneration.QueryComposition.QueryParts.BuildCountQuery C# (CSharp) Method

BuildCountQuery() protected method

protected BuildCountQuery ( ResultOperatorBase countOperator ) : string
countOperator ResultOperatorBase
return string
        protected string BuildCountQuery(ResultOperatorBase countOperator)
        {
            Selects.Clear();
            CurrentSelectIndex = 0;

            var sb = new StringBuilder();
            sb.Append("SELECT ");
            if (countOperator is LongCountResultOperator)
            {
                AddSelectPart(MainFrom, "COUNT(*)", "count", typeof(long), (_, __, dr) => dr.GetInt64(0));
                sb.AppendLine("COUNT(*)");
            }
            else
            {
                AddSelectPart(MainFrom, "COUNT(*)::int", "count", typeof(int), (_, __, dr) => dr.GetInt32(0));
                sb.AppendLine("COUNT(*)::int");
            }
            sb.Append(GetFromPart());
            sb.Append(GetWherePart());

            return sb.ToString();
        }