Adb Information
Adb provides classes and members for retrieving and processing meta-data about a data source. This information assists with for instance:
- Implementing new database access functionality, e.g. getting a list of all columns in a database table, so that an SQL query can be automatically created
- Writing provider-independent database code, e.g. retrieving how to quote a database identifier, so that database workers can operate against all supported databases
Informational members:
AdbProvider member:
AdbConnectionBuilder members:
AdbConnection members:
- DatabaseName, DataSourceName, NumberOfColumnIdentifierParts, NumberOfColumnRestrictions, Provider, ServerVersion
- GetSchema(String) overloads and SchemaInformationCollection, lower level APIs, use other members where possible
- Information (AdbDataSourceInformation) - query writing information members:
- TableInformation (AdbTableInformation)
members:
- GetTableColumnsAsync(String) overloads
- CreateTableIdentifier(String)
- GetTableTypeAsync(String) overloads
Information Example
Here we create a connection and output information about a data source to the console, using the APIs listed above.
The output of this program is included on each of the Adb provider pages.
Note
A typical ETL application would obviously have no need to dump these settings to the console. It is however useful to see what settings are available and their typical values. Do consider using individual settings, especially when creating reusable workers that must support arbitrary Adb database providers.
using System;
using System.Linq;
using actionETL.Adb;
public static class AdbInformation
{
public static void RunExample(
AdbConnectionString adbConnectionString
, string tableName
)
{
var cb = adbConnectionString.CreateConnectionBuilder();
Console.WriteLine($@"=====================================================================
=== AdbConnectionBuilder ===
Provider={cb.Provider}
");
using (var cn = cb.Create())
{
cn.Open();
Console.WriteLine($@"
=== AdbConnection ===
DataSourceName={cn.DataSourceName}
DatabaseName={cn.DatabaseName}
NumberOfColumnIdentifierParts={cn.NumberOfColumnIdentifierParts}
NumberOfColumnRestrictions={cn.NumberOfColumnRestrictions}
ServerVersion={cn.ServerVersion}
");
Console.WriteLine($@"
=== AdbConnection.Information ===
{cn.Information}
");
var ti = cn.TableInformation;
if (ti != null)
{
Console.WriteLine($@"
=== AdbConnection.TableInformation.CreateTableIdentifier({tableName}) ===
{ti.CreateTableIdentifier(tableName).ToLongString()}
");
}
Console.WriteLine($@"
=== AdbConnection.SchemaInformationCollection ===
Note: The metadata schemas can be retrieved with AdbConnection.GetSchema().
The returned information is provided from the .NET provider as-is. Some collections
can be inaccurate, and different values can also be needed for different purposes,
which is why database specific actionETL providers can be created that replace
individual values with the desired ones. See the vendor provider documentation for
details on the returned information.
{string.Join(Environment.NewLine, cn.SchemaInformationCollection
.Select(mdc => mdc + Environment.NewLine))}
");
}
}
}