Generic.DatabaseFactory
1.0.0
dotnet add package Generic.DatabaseFactory --version 1.0.0
NuGet\Install-Package Generic.DatabaseFactory -Version 1.0.0
<PackageReference Include="Generic.DatabaseFactory" Version="1.0.0" />
<PackageVersion Include="Generic.DatabaseFactory" Version="1.0.0" />
<PackageReference Include="Generic.DatabaseFactory" />
paket add Generic.DatabaseFactory --version 1.0.0
#r "nuget: Generic.DatabaseFactory, 1.0.0"
#:package Generic.DatabaseFactory@1.0.0
#addin nuget:?package=Generic.DatabaseFactory&version=1.0.0
#tool nuget:?package=Generic.DatabaseFactory&version=1.0.0
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:
- 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>
- 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net is compatible. |
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