RowCountTask

Class RowCountTask

Count the row in a table. This task normally uses the COUNT(*) method (could take some time on big tables). You can pass a a filter condition for the count.

Inheritance
RowCountTask
Implements
Namespace: ETLBox.ControlFlow
Assembly: ETLBox.dll
Syntax
    public sealed class RowCountTask : ControlFlowTask, ILoggableTask
Examples
int count = RowCountTask.Count("tableName").Value;

Constructors

RowCountTask()

Declaration
    public RowCountTask()

RowCountTask(string)

Declaration
    public RowCountTask(string tableName)
Parameters
TypeNameDescription
stringtableName

RowCountTask(string, RowCountOptions)

Declaration
    public RowCountTask(string tableName, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
RowCountOptionsoptions

RowCountTask(string, string)

Declaration
    public RowCountTask(string tableName, string condition)
Parameters
TypeNameDescription
stringtableName
stringcondition

RowCountTask(string, string, RowCountOptions)

Declaration
    public RowCountTask(string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
stringcondition
RowCountOptionsoptions

Properties

Condition

Part of the sql where condition which restrict which rows are counted

Declaration
    public string Condition { get; set; }
Property Value
TypeDescription
string

DirtyRead

Will do the row count also on uncommitted reads.

Declaration
    public bool DirtyRead { get; }
Property Value
TypeDescription
bool

Options

For Sql Server, you can set the QuickQueryMode to true. This will query the sys.partition table which can be much faster. If set to DirtyRead, the count will also read uncommitted rows. If set ReadOnlyFirstRow, the count will use a limit when running

Declaration
    public RowCountOptions Options { get; set; }
Property Value
TypeDescription
RowCountOptions

QuickQueryMode

For Sql Server, you can set the QuickQueryMode to true. This will query the sys.partition table which can be much faster.

Declaration
    public bool QuickQueryMode { get; }
Property Value
TypeDescription
bool

Rows

Will hold the number of counted rows after execution

Declaration
    public int? Rows { get; }
Property Value
TypeDescription
int?

Sql

The sql that is executed to count the rows in the table - will change depending on your parameters.

Declaration
    public string Sql { get; }
Property Value
TypeDescription
string

TN

The formatted table table name

Declaration
    public ObjectNameDescriptor TN { get; }
Property Value
TypeDescription
ObjectNameDescriptor

TableName

Name of the table on which the rows are counted

Declaration
    public string TableName { get; set; }
Property Value
TypeDescription
string

Methods

Count()

Performs the row count

Declaration
    public int Count()
Returns
TypeDescription
int

Count(IConnectionManager, string)

Declaration
    public static int Count(IConnectionManager connectionManager, string tableName)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
Returns
TypeDescription
int

Count(IConnectionManager, string, RowCountOptions)

Declaration
    public static int Count(IConnectionManager connectionManager, string tableName, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
RowCountOptionsoptions
Returns
TypeDescription
int

Count(IConnectionManager, string, string)

Declaration
    public static int Count(IConnectionManager connectionManager, string tableName, string condition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
Returns
TypeDescription
int

Count(IConnectionManager, string, string, RowCountOptions)

Declaration
    public static int Count(IConnectionManager connectionManager, string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
RowCountOptionsoptions
Returns
TypeDescription
int

Count(string)

Declaration
    public static int Count(string tableName)
Parameters
TypeNameDescription
stringtableName
Returns
TypeDescription
int

Count(string, RowCountOptions)

Declaration
    public static int Count(string tableName, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
RowCountOptionsoptions
Returns
TypeDescription
int

Count(string, string)

Declaration
    public static int Count(string tableName, string condition)
Parameters
TypeNameDescription
stringtableName
stringcondition
Returns
TypeDescription
int

Count(string, string, RowCountOptions)

Declaration
    public static int Count(string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
stringcondition
RowCountOptionsoptions
Returns
TypeDescription
int

CountAsync()

Performs the row count

Declaration
    public Task<int> CountAsync()
Returns
TypeDescription
Task<int>

CountAsync(IConnectionManager, string)

Declaration
    public static Task<int> CountAsync(IConnectionManager connectionManager, string tableName)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
Returns
TypeDescription
Task<int>

CountAsync(IConnectionManager, string, RowCountOptions)

Declaration
    public static Task<int> CountAsync(IConnectionManager connectionManager, string tableName, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
RowCountOptionsoptions
Returns
TypeDescription
Task<int>

CountAsync(IConnectionManager, string, string)

Declaration
    public static Task<int> CountAsync(IConnectionManager connectionManager, string tableName, string condition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
Returns
TypeDescription
Task<int>

CountAsync(IConnectionManager, string, string, RowCountOptions)

Declaration
    public static Task<int> CountAsync(IConnectionManager connectionManager, string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
RowCountOptionsoptions
Returns
TypeDescription
Task<int>

HasRows()

Checks if the table has at least one (matching) row.

Declaration
    public bool HasRows()
Returns
TypeDescription
bool

HasRows(IConnectionManager, string)

Declaration
    public static bool HasRows(IConnectionManager connectionManager, string tableName)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
Returns
TypeDescription
bool

HasRows(IConnectionManager, string, RowCountOptions)

Declaration
    public static bool HasRows(IConnectionManager connectionManager, string tableName, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
RowCountOptionsoptions
Returns
TypeDescription
bool

HasRows(IConnectionManager, string, string)

Declaration
    public static bool HasRows(IConnectionManager connectionManager, string tableName, string condition)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
Returns
TypeDescription
bool

HasRows(IConnectionManager, string, string, RowCountOptions)

Declaration
    public static bool HasRows(IConnectionManager connectionManager, string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
IConnectionManagerconnectionManager
stringtableName
stringcondition
RowCountOptionsoptions
Returns
TypeDescription
bool

HasRows(string)

Declaration
    public static bool HasRows(string tableName)
Parameters
TypeNameDescription
stringtableName
Returns
TypeDescription
bool

HasRows(string, RowCountOptions)

Declaration
    public static bool HasRows(string tableName, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
RowCountOptionsoptions
Returns
TypeDescription
bool

HasRows(string, string)

Declaration
    public static bool HasRows(string tableName, string condition)
Parameters
TypeNameDescription
stringtableName
stringcondition
Returns
TypeDescription
bool

HasRows(string, string, RowCountOptions)

Declaration
    public static bool HasRows(string tableName, string condition, RowCountOptions options)
Parameters
TypeNameDescription
stringtableName
stringcondition
RowCountOptionsoptions
Returns
TypeDescription
bool

Implements