I have two executables that access a DLL containing Data Access Layer objects
Each exe can have a different config containing info on server and
database name, connection string etc.
How do I pass the config info to the DAL objects?
Obviously I can pass the config strings to the DAL objects
every time I instanciate one, but that seems messy and repetitive as every class in the DAL will require Properties for the Config strings..
Can anyone tell me if there is a better way?
I am wondering if there is a way for the instanciated DAL objects to read some properties from the calling object without me having to pass them explicitly?
What about having all DAL classes derive from a base class which contains the connection string property?
In that case, you could call the base’s constructor on the child contructor invocation and that base contructor would then be the single place for loading the Connection string.
If you have the same ConfigKey used in both Exe’s eg: “DBConnectionString” – then the contructor will just load the values from config files “DBConnection” entry – no matter which exe is calling the dal and the correct value of connection string will be passed to it
Implementation would be something on below lines…
Sorry for using C# – like syntax. i last used VB very many years ago.