Пример #1
0
        public static string Count(this ISqlDialect d, IDataDescriptor descriptor, List <Filter> filter = null)
        {
            return(Pooling.StringBuilderPool.Scoped(sb =>
            {
                sb.Append("SELECT ");

                sb.Append(d.Count);

                if (filter?.Count > 0)
                {
                    sb.Append($" {d.Where(filter)}");
                }

                d.AfterCount(descriptor, sb, filter?.Count > 0);
            }));
        }
Пример #2
0
        public static string Count <T>(this ISqlDialect dialect, IDataDescriptor descriptor, FilterOptions filter = null)
        {
            return(StringBuilderPool.Scoped(sb =>
            {
                // SELECT COUNT(1) FROM ...
                sb.Append(
                    $"SELECT {dialect.Count} FROM {dialect.StartIdentifier}{typeof(T).Name}{dialect.EndIdentifier}");

                // WHERE ...
                if (filter?.Fields.Count > 0)
                {
                    sb.Append($" {dialect.Where(filter)}");
                }

                dialect.AfterCount(descriptor, sb, filter?.Fields.Count > 0);
            }));
        }
Пример #3
0
        public static string Count(this ISqlDialect d, IDataDescriptor descriptor, string table, string schema,
                                   List <string> keys, List <string> parameters)
        {
            return(Pooling.StringBuilderPool.Scoped(sb =>
            {
                if (descriptor != null && !d.BeforeSelect(descriptor, sb))
                {
                    return;
                }

                sb.Append("SELECT ");

                sb.Append(d.Count);

                sb.Append(" FROM ").AppendTable(d, table, schema);

                if (keys?.Count > 0)
                {
                    sb.AppendWhereClause(descriptor, d, keys, parameters);
                }

                d.AfterCount(descriptor, sb, keys?.Count > 0);
            }));
        }