ReportingConnections

Classes > Nimblesite.Reporting.Api > ReportingConnections

Server-side connection registry for report data sources. Each connection string is opened with the provider it targets (SQLite, PostgreSQL or SQL Server), and LQL is transpiled for that provider. Implements [REPORT-CONNECTIONS].

public static class ReportingConnections

Methods

FromConfiguration(IConfiguration)

public static ImmutableDictionary<string, ConnectionConfig> FromConfiguration(IConfiguration configuration)

Builds the registry from ConnectionStrings:*. ConnectionProviders:{name} (Sqlite, Postgres or SqlServer) overrides provider detection for a connection.

Parameters:

Name Type Description
configuration IConfiguration Application configuration.

Returns: ConnectionConfig> - Connection configs keyed by connection ref.

DetectProvider(string)

public static DatabaseProvider DetectProvider(string connectionString)

Detects the provider from connection string keywords, parsed with the ADO.NET connection string parser: PostgreSQL-specific keywords take precedence over the shared Server alias; SQL Server keywords are SQL Server, anything else is a SQLite data source.

Parameters:

Name Type Description
connectionString String The connection string to inspect.

Returns: DatabaseProvider - The detected provider.

Open(ImmutableDictionary<string, ConnectionConfig>, string)

public static Result<IDbConnection, SqlError> Open(ImmutableDictionary<string, ConnectionConfig> connections, string connectionRef)

Opens the connection registered under connectionRef.

Parameters:

Name Type Description
connections ConnectionConfig> The connection registry.
connectionRef String The report data source's connection ref.

Returns: SqlError> - An open connection the caller owns, or an error.

Transpile(ImmutableDictionary<string, ConnectionConfig>, string, string)

public static Result<string, SqlError> Transpile(ImmutableDictionary<string, ConnectionConfig> connections, string connectionRef, string lqlCode)

Transpiles LQL to SQL for the provider behind connectionRef.

Parameters:

Name Type Description
connections ConnectionConfig> The connection registry.
connectionRef String The report data source's connection ref.
lqlCode String The LQL query.

Returns: SqlError> - Provider SQL, or an error.