From d51ec32938f7bb4c85ab2d6aa330b257d920eb69 Mon Sep 17 00:00:00 2001 From: Stelio Kontos <37424493+Ste1io@users.noreply.github.com> Date: Mon, 9 Oct 2023 11:28:17 -0500 Subject: [PATCH] update DatabaseProvider class doc comments --- PetaPoco/Core/DatabaseProvider.cs | 10 +++++++--- PetaPoco/Core/IProvider.cs | 2 +- PetaPoco/OracleProvider.cs | 14 +++++++------- PetaPoco/Providers/FirebirdDatabaseProvider.cs | 6 +++++- PetaPoco/Providers/MSAccessDatabaseProvider.cs | 10 +++++++--- PetaPoco/Providers/MariaDBDatabaseProvider.cs | 5 +++-- .../Providers/MySqlConnectorDatabaseProvider.cs | 5 ++++- PetaPoco/Providers/MySqlDatabaseProvider.cs | 5 ++++- PetaPoco/Providers/OracleDatabaseProvider.cs | 5 ++++- PetaPoco/Providers/PostgresDatabaseProvider.cs | 6 +++++- PetaPoco/Providers/SQLiteDatabaseProvider.cs | 7 +++++-- PetaPoco/Providers/SqlServerCeDatabaseProviders.cs | 7 ++++++- PetaPoco/Providers/SqlServerDatabaseProvider.cs | 10 ++++++++-- .../Providers/SqlServerMSDataDatabaseProvider.cs | 5 +++-- 14 files changed, 69 insertions(+), 28 deletions(-) diff --git a/PetaPoco/Core/DatabaseProvider.cs b/PetaPoco/Core/DatabaseProvider.cs index 65911993..6485a169 100644 --- a/PetaPoco/Core/DatabaseProvider.cs +++ b/PetaPoco/Core/DatabaseProvider.cs @@ -14,9 +14,13 @@ namespace PetaPoco.Core { /// - /// The DatabaseProvider class defines a base implementation for database Provider classes, and provides common defaults used by - /// different database management systems. + /// Provides an abstract base class for database providers. This class implements common functionality and provides default behavior for + /// specialized database providers. /// + /// + /// This class includes methods for database-specific operations like parameter handling, SQL escaping, and paging, among others. + /// Derived classes should override these methods to implement behavior specific to the database they target. + /// public abstract class DatabaseProvider : IProvider { private static readonly ConcurrentDictionary customProviders = new ConcurrentDictionary(); @@ -101,7 +105,7 @@ protected DbProviderFactory GetFactory(params string[] assemblyQualifiedNames) if (ft == null) throw new ArgumentException($"Could not load the {GetType().Name} DbProviderFactory."); - return (DbProviderFactory) ft.GetField("Instance").GetValue(null); + return (DbProviderFactory)ft.GetField("Instance").GetValue(null); } /// diff --git a/PetaPoco/Core/IProvider.cs b/PetaPoco/Core/IProvider.cs index 3ec7ca57..4f724173 100644 --- a/PetaPoco/Core/IProvider.cs +++ b/PetaPoco/Core/IProvider.cs @@ -9,7 +9,7 @@ namespace PetaPoco.Core { /// - /// Represents a contract for a database type provider. + /// Defines the contract for database providers that expose functionality for connecting to various types of databases. /// public interface IProvider { diff --git a/PetaPoco/OracleProvider.cs b/PetaPoco/OracleProvider.cs index 9988e87f..80f47cc9 100644 --- a/PetaPoco/OracleProvider.cs +++ b/PetaPoco/OracleProvider.cs @@ -5,13 +5,13 @@ namespace PetaPoco { /// - /// Pprovides an implementation of for early versions of the Oracle drivers that don't include it. + /// Provides an implementation of for Oracle databases using the unmanaged Oracle Data Provider. /// /// - /// For later versions of Oracle, the standard OracleProviderFactory class should work fine. - /// Uses reflection to load Oracle.DataAccess assembly and in-turn create connections and commands. - /// Thanks to Adam Schroder (@schotime) for this. - /// Currently untested. + /// This provider uses the "Oracle.DataAccess.Client" ADO.NET driver for data access. For later versions of Oracle, the managed class should work fine. Uses reflection to load "Oracle.DataAccess" assembly and in-turn + /// create connections and commands. + /// Thanks to Adam Schroder (@schotime) for this. Currently untested. /// /// /// @@ -69,7 +69,7 @@ public OracleProvider() /// A new . public override DbConnection CreateConnection() { - return (DbConnection) Activator.CreateInstance(_connectionType); + return (DbConnection)Activator.CreateInstance(_connectionType); } /// @@ -78,7 +78,7 @@ public override DbConnection CreateConnection() /// A new . public override DbCommand CreateCommand() { - DbCommand command = (DbCommand) Activator.CreateInstance(_commandType); + DbCommand command = (DbCommand)Activator.CreateInstance(_commandType); var oracleCommandBindByName = _commandType.GetProperty("BindByName"); oracleCommandBindByName.SetValue(command, true, null); diff --git a/PetaPoco/Providers/FirebirdDatabaseProvider.cs b/PetaPoco/Providers/FirebirdDatabaseProvider.cs index 523f7939..5c2fdbad 100644 --- a/PetaPoco/Providers/FirebirdDatabaseProvider.cs +++ b/PetaPoco/Providers/FirebirdDatabaseProvider.cs @@ -11,9 +11,13 @@ namespace PetaPoco.Providers { // TODO: Rename class: FirebirdDatabaseProvider + /// - /// Provides a specific implementation of the class for Firebird. + /// Provides an implementation of for Firebird databases. /// + /// + /// This provider uses the "FirebirdSql.Data.FirebirdClient" ADO.NET driver for data access. + /// public class FirebirdDbDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/MSAccessDatabaseProvider.cs b/PetaPoco/Providers/MSAccessDatabaseProvider.cs index bc80f9a5..5066b392 100644 --- a/PetaPoco/Providers/MSAccessDatabaseProvider.cs +++ b/PetaPoco/Providers/MSAccessDatabaseProvider.cs @@ -11,9 +11,13 @@ namespace PetaPoco.Providers { // TODO: Rename class: MSAccessDatabaseProvider + /// - /// Provides a specific implementation of the class for Microsoft Access. + /// Provides an implementation of for Microsoft Access databases. /// + /// + /// This provider uses the "System.Data.OleDb" ADO.NET driver for data access. + /// public class MsAccessDbDatabaseProvider : DatabaseProvider { /// @@ -39,10 +43,10 @@ public override async Task ExecuteInsertAsync(CancellationToken cancella #endif /// - /// Page queries are not supported by MsAccess database. + /// Page queries are not supported by MS Access database. /// /// This method always throws a . - /// The MsAccess provider does not support paging. + /// The MS Access provider does not support paging. /// public override string BuildPageQuery(long skip, long take, SQLParts parts, ref object[] args) => throw new NotSupportedException("The MS Access provider does not support paging."); diff --git a/PetaPoco/Providers/MariaDBDatabaseProvider.cs b/PetaPoco/Providers/MariaDBDatabaseProvider.cs index 5171fe4d..eb37eaaa 100644 --- a/PetaPoco/Providers/MariaDBDatabaseProvider.cs +++ b/PetaPoco/Providers/MariaDBDatabaseProvider.cs @@ -5,11 +5,12 @@ namespace PetaPoco.Providers { // TODO: Rename class: MariaDBDatabaseProvider + /// - /// Provides a specific implementation of the class for MariaDB. + /// Provides an implementation of for MariaDB databases. /// /// - /// This class uses the provider. + /// This provider uses the "MySql.Data.MySqlClient" ADO.NET driver for data access. /// public class MariaDbDatabaseProvider : DatabaseProvider { diff --git a/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs b/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs index a7bb7d1f..e0ae636e 100644 --- a/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs +++ b/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs @@ -5,8 +5,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for MySQL using the MySqlConnector library. + /// Provides an implementation of for MySQL databases using the MySqlConnector library. /// + /// + /// This provider uses the "MySqlConnector" ADO.NET driver for data access. + /// public class MySqlConnectorDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/MySqlDatabaseProvider.cs b/PetaPoco/Providers/MySqlDatabaseProvider.cs index 69a180fe..954defe9 100644 --- a/PetaPoco/Providers/MySqlDatabaseProvider.cs +++ b/PetaPoco/Providers/MySqlDatabaseProvider.cs @@ -5,8 +5,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for MySQL. + /// Provides an implementation of for MySQL databases. /// + /// + /// This provider uses the "MySql.Data.MySqlClient" ADO.NET driver for data access. + /// public class MySqlDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/OracleDatabaseProvider.cs b/PetaPoco/Providers/OracleDatabaseProvider.cs index cfd5dc62..7a06a2b6 100644 --- a/PetaPoco/Providers/OracleDatabaseProvider.cs +++ b/PetaPoco/Providers/OracleDatabaseProvider.cs @@ -12,8 +12,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for Oracle. + /// Provides an implementation of for Oracle databases using the managed Oracle Data Provider. /// + /// + /// This provider uses the "Oracle.ManagedDataAccess.Client" ADO.NET driver for data access. + /// public class OracleDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/PostgresDatabaseProvider.cs b/PetaPoco/Providers/PostgresDatabaseProvider.cs index a9a77a08..ce3a79c7 100644 --- a/PetaPoco/Providers/PostgresDatabaseProvider.cs +++ b/PetaPoco/Providers/PostgresDatabaseProvider.cs @@ -9,9 +9,13 @@ namespace PetaPoco.Providers { // TODO: Rename class: PostgresDatabaseProvider + /// - /// Provides a specific implementation of the class for PostgreSQL. + /// Provides an implementation of for PostgreSQL databases. /// + /// + /// This provider uses the "Npgsql" ADO.NET driver for data access. + /// public class PostgreSQLDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/SQLiteDatabaseProvider.cs b/PetaPoco/Providers/SQLiteDatabaseProvider.cs index b4b3d204..c42d51ff 100644 --- a/PetaPoco/Providers/SQLiteDatabaseProvider.cs +++ b/PetaPoco/Providers/SQLiteDatabaseProvider.cs @@ -7,8 +7,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for SQLite. + /// Provides an implementation of for SQLite databases. /// + /// + /// This provider can use either the "System.Data.SQLite" or "Microsoft.Data.Sqlite" ADO.NET drivers for data access. + /// public class SQLiteDatabaseProvider : DatabaseProvider { /// @@ -19,7 +22,7 @@ public override DbProviderFactory GetFactory() public override object MapParameterValue(object value) { if (value is uint u) - return (long) u; + return (long)u; return base.MapParameterValue(value); } diff --git a/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs b/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs index ea7e87b9..5e6e4c36 100644 --- a/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs +++ b/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs @@ -9,9 +9,14 @@ namespace PetaPoco.Providers { // TODO: Rename class: SqlServerCeDatabaseProvider + /// - /// Provides a specific implementation of the class for SQL Server CE. + /// Provides an implementation of for Microsoft SQL Server Compact Edition databases. /// + /// + /// This provider uses the "System.Data.SqlServerCe" ADO.NET driver for data access. Note that this driver is end-of-life (reference). + /// public class SqlServerCEDatabaseProviders : DatabaseProvider { /// diff --git a/PetaPoco/Providers/SqlServerDatabaseProvider.cs b/PetaPoco/Providers/SqlServerDatabaseProvider.cs index fb7b0167..cc72d13e 100644 --- a/PetaPoco/Providers/SqlServerDatabaseProvider.cs +++ b/PetaPoco/Providers/SqlServerDatabaseProvider.cs @@ -9,8 +9,14 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for SQL Server. + /// Provides an implementation of for Microsoft SQL Server databases. /// + /// + /// This provider uses the "System.Data.SqlClient" ADO.NET driver for data access. Note that this driver is end-of-life (reference and + /// more info). Consider using as an alternative, which uses the "Microsoft.Data.SqlClient" driver. + /// public class SqlServerDatabaseProvider : DatabaseProvider { /// @@ -20,7 +26,7 @@ public override DbProviderFactory GetFactory() /// public override string BuildPageQuery(long skip, long take, SQLParts parts, ref object[] args) { - var helper = (PagingHelper) PagingUtility; + var helper = (PagingHelper)PagingUtility; // when the query does not contain an "order by", it is very slow if (helper.SimpleRegexOrderBy.IsMatch(parts.SqlSelectRemoved)) { diff --git a/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs b/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs index 896a6325..f55b1b62 100644 --- a/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs +++ b/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs @@ -4,11 +4,12 @@ namespace PetaPoco.Providers { // TODO: Rename class: SqlServerMSDataDatabaseProvider + /// - /// Provides a specific implementation of the class for Microsoft.Data.SqlClient. + /// Provides an implementation of for Microsoft SQL Server databases. /// /// - /// This class serves as a wrapper for the class. + /// This provider uses the "Microsoft.Data.SqlClient" ADO.NET driver for data access. /// public class SqlServerMsDataDatabaseProvider : SqlServerDatabaseProvider {