There's a lengthy running habit here where Sometimes the connection string lives within the web.config, a Sql Connection object is instantiated inside a using block with this connection string and passed towards the DataObjects constructor (using a CreateInstance Method because the constructor is private). Something similar to this:

using(SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
    DataObject foo = DataObject.CreateInstance(conn);
    foo.someProperty = "some value";

All of this smells in my experience.. I'm not sure. Should not the DataLayer class library result in Connection objects and Connection strings? I'd be grateful to be aware what other medication is doing or worthwhile online articles about these type of design choices.

Take into account that the projects we focus on will always be Sql Server backends which is very unlikely to alter. So factory and provider pattern isn't what I am after. It's much more about where responsibility lies and where config configurations ought to be handled for data layer operation.

I love to code the classes during my data access layer to ensure that they've one constructor that can take an IDbConnection like a parameter, and the other that can take a (connection) string.

This way the calling code may either construct its very own SqlConnection and pass it in (handy for integration tests), mock an IDbConnection and pass that in (handy for unit tests) or read an association string from the configuration file (eg web.config) and pass that in.

this as being a "smell" is relative. if you're confident about coupling this specific bit of code to SQL Server along with a web.config connection string entry then it is perfectly OK. if you're not into this type of coupling, To be sure that it's a code smell and it is undesirable.

Hm, I believe To be sure the datalayer should result in controlling such connection strings therefore the greater layers don't have to be worried about this. However, I don't believe that the SQLConnection should worry in which the connection string originates from.

I believe, I'd possess a datalayer which supplies certain DataInputs, that's, stuff that have a condition and return DataObjects. This type of DataInput now knows "hey, this DataObjects are saved for the reason that Database, and taking advantage of the Designs, I'm able to apply certain connection-string to obtain an SQL-Connection from there.

This way you've exemplified the whole process of "Where and how perform the data objects originate from?Inch and also the internals from the datalayer can nonetheless be examined correctly. (And, as an unwanted effect, it is simple to use different databases, as well as multiple different databases simultaneously. Such versatility that simply appears is a great sign(tm))