Java’s datasource is equivalent to net
Yes Net (especially c# true), is there a datasource class equivalent to Java? I'm used to creating a single datasource (pooled or non pooled) and passing it to the object that needs to create a new database connection It is helpful in the case of decoupling / dependency injection
But in Net, the instantiation of the new SqlConnection seems to come from the pool if you use the same connection string Does this mean that you should pass the connection string (or connection string builder) to the Dao pattern class, just pass a single connection object or create a new connectionprovider?
for example
class SomethingDao { DataSource dataSource; Something getSomething(int id) { connection = dataSource.GetConnection(); connection.CreateCommand(); ... etc } }
Solution
The enterprise library can handle almost all of these details for you, so I suggest you consider using it and follow the example code shown here:
http://msdn.microsoft.com/en-us/library/ff953187%28v=PandP.50%29.aspx
This link guides you step - by - step through it The equivalent of using ent lib will be the database class It contains all the code examples, so I won't repeat it here