Generic.DatabaseFactory 1.0.0

dotnet add package Generic.DatabaseFactory --version 1.0.0
                    
NuGet\Install-Package Generic.DatabaseFactory -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Generic.DatabaseFactory" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Generic.DatabaseFactory" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Generic.DatabaseFactory" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Generic.DatabaseFactory --version 1.0.0
                    
#r "nuget: Generic.DatabaseFactory, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Generic.DatabaseFactory@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Generic.DatabaseFactory&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Generic.DatabaseFactory&version=1.0.0
                    
Install as a Cake Tool

Generic.DatabaseFactory 1.0.0 Library implements the Database Factory Design Pattern.

To use the Generic.DatabaseFactory library in your .NET project following the steps below:

  1. Add the following sections to the App.config file: <configSections> <section name="DatabaseFactoryConfiguration" type="Generic.DatabaseFactory.DatabaseFactorySectionHandler, Generic.DatabaseFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </configSections>

Add your database connection string <add name="YourConnectionString" connectionString="XXXXX" providerName="XXXXX"/>

Indicate to the Database Factory which connection string you are supplying it with – either Generic.DatabaseFactory.OracleDatabase or Generic.DatabaseFactory.SQLDatabase <DatabaseFactoryConfiguration Name="Generic.DatabaseFactory.OracleDatabase" ConnectionStringName="YourConnectionString" />

Sample App.config file:

<?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="DatabaseFactoryConfiguration" type="Generic.DatabaseFactory.DatabaseFactorySectionHandler, Generic.DatabaseFactory, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </configSections> <connectionStrings> <clear/> <add name="MyConnection1" providerName="Oracle.DataAccess.Client" connectionString="Your Connection String Here" /> <add name="MyConnection2" providerName="System.Data.OracleClient" connectionString="Your Connection String Here" /> </connectionStrings>

<DatabaseFactoryConfiguration Name="Generic.DatabaseFactory.OracleDatabase" ConnectionStringName="MyConnection1" /> </configuration>

  1. Use the DataWorker class as the base class for your database implementation:

Sample Class that inherits from the DataWorker Base Class:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using Generic.DatabaseFactory; using System.Data;

namespace TestGenericDatabaseFactory { class Program : DataWorker { static void Main(string[] args) { GetTestData(); }

    static void GetTestData()
    {
        string SQLQuery = "SELECT * FROM SOME_TABLE";

        using (IDbConnection connection = database.CreateOpenConnection())
        {
            using (IDbCommand command = database.CreateCommand(SQLQuery, connection))
            {
                using (IDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        //Do something
                    }
                }
            }
        }
    }
}

}

And you’re done! Happy Coding 😃

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 2,225 4/12/2017

Initial Release