I am strugling to get the proper/best way to handle a connection string in an other project:
I have two projects in a VS solution:
Project 1: website (asp.net)
- with web.config has a db connection string
Project 2: with some classes
- with data layer (to be accessed in project 1 or project x)
What is the proper way to set the connection string in project 2?
Project 2 has a static class with function like:
public static List<T> GetData();
Should I always pass the connection string as an variable like:
public static List<T> GetData(string connectionString);
So syntax like i.e.:
var connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"];
var list = ClassX.GetData(connectionString);
Or is it possible to set in general somewhere in an other way?
Or is my complete setup wrong? :)