I'm planning to extend my application. At the moment, I have Data.dll that uses Data Access that uses SQL Server with Stored Procedure. What I would to do is to make it flexible where changing the DLL will change the Data Access to any provider like MySQL or Oracle. The goal is to avoid making changes on the Main Application. I'm just not sure what is the best way to implement this in C#. At the moment, I'm using win32 but wanted to use the same concept on my other ASP.NET Core API. I'm planning to use App.config for Win32 or Web.config for the WebApi to make changes on the configuration.
-----UPDATE to MAKE IT MORE CLEARER ---------
I've just created 3 Projects Project# 1 - A DLL that will Perform CRUD on SQL Server and produce a file called DLLClassLibrary.dll
public class Data
{
public string GetName()
{
return "NAME DLL SQL SERVER";
}
}
Project# 2 - A DLL that will Perform CRUD on MySQL and produce a file called DLLClassLibrary.dll
public class Data
{
public string GetName()
{
return "NAME DLL MYSQL";
}
}
Project# 3 - The MAIN app where I will consume the DLL. On the program, I've created a reference to a file called DLLClassLibrary.dll.
public partial class frmMain : Form
{
DLLClassLibrary.Data data = new DLLClassLibrary.Data();
public frmMain()
{
InitializeComponent();
}
private void frmMain_Load(object sender, EventArgs e)
{
txtOut.Text = data.GetName();
}
}
Test Done using Project # 1 generated DLL
Test Done using Project # 2 generated DLL
As you can see by placing the same dll file the behaviour changes. The question is what is the best way to implement these 2 DLLs without removing one another and without Hard Coding it on my Main. Or is that the only option?