/// <summary> /// Creates a command which will count how many entities are in the table. /// </summary> public static CommandDefinition MakeCountCommand <TEntity>( string conditions, object parameters, IDbTransaction transaction, IDialect dialect, int?commandTimeout, CancellationToken cancellationToken = default(CancellationToken)) { var config = MicroCRUDConfig.Current; dialect = dialect ?? config.Dialect; var tableSchema = TableSchemaFactory.GetTableSchema(typeof(TEntity), dialect, config.SchemaFactory); var sql = dialect.MakeCountStatement(tableSchema, conditions); return(MakeCommandDefinition(sql, parameters, transaction, commandTimeout, cancellationToken)); }
/// <summary> /// Creates a command which will count how many entities are in the table. /// </summary> public static CommandDefinition MakeCountCommand <TEntity>( object conditions, IDbTransaction transaction, IDialect dialect, int?commandTimeout, CancellationToken cancellationToken = default(CancellationToken)) { Ensure.NotNull(conditions, nameof(conditions)); var config = MicroCRUDConfig.Current; dialect = dialect ?? config.Dialect; var entityType = typeof(TEntity); var tableSchema = TableSchemaFactory.GetTableSchema(entityType, dialect, config.SchemaFactory); var conditionsSchema = TableSchemaFactory.GetConditionsSchema(entityType, tableSchema, conditions.GetType(), dialect, config.SchemaFactory); var sql = dialect.MakeCountStatement(tableSchema, dialect.MakeWhereClause(conditionsSchema, conditions)); return(MakeCommandDefinition(sql, conditions, transaction, commandTimeout, cancellationToken)); }