TableVet ClassCleanCode C# Libraries v1.2.03 API
Provides simple support for vetting one or more database tables (SQL Server only).
Inheritance Hierarchy

OnlineSystem Object
  CleanCode.Data TableVet

Namespace: CleanCode.Data
Assembly: CleanCode (in CleanCode.dll) Version: 1.2.3.0 (1.2.03)
Syntax

public class TableVet : IDisposable
Remarks

This class allows you to do a sanity check on selected tables in your database, checking both for non-empty tables and for certain data in your tables. This first example shows a technique for making sure a group of tables are not empty.
TableVet tableVetter = new TableVet();
tableVetter.Connect(userName, pwd, source, catalog);
string[] tablesToVet = { "table1", "table2" };
foreach (string tableName in tablesToVet)
{
    if (!tableVetter.Vet(tableName))
    {
        MessageBox.Show("Empty table detected: " + tableName);
    }
}
tableVetter.Close();
string[,] tablesToVet = {
    { "table1", "range > 100" },
    { "table2", "id like 'A%' and index = 0" },
};
for (int i = 0; i < tablesToVet.GetLength(0); i++)
{
    string tableName = tablesToVet[i, 0];
    string clause = tablesToVet[i, 1];
    if (!tableVetter.Vet(tableName, clause))
    {
        MessageBox.Show(string.format(
            "table {0} failed assertion {1}: ", tableName, clause));
    }
}
This next example shows how to check for conditions other than empty:

Since CleanCode 0.9.07.

See Also