M
Mark
I am building my first .NET data access layer but have run in an problem and
would be interested in hearing opinions from more experienced .NET
developers.
I am building a data access layer that encapsulates my business entities.
For simplicity sake, say I have a .Load and a .Store method for each
business entity in each DAL. Each DAL then has it's own ConnectionString
property and therefore each .Load and .Store method opens it's own
SqlConnection and issues the relevant SQL commands. In theory there should
be no performance loss because of connection pooling.
The problem is that in the application layer I sometimes need to store
multiple business entites within a transaction. Since each DAL opens it's
own SqlConnection this can't be done (or can it?)
The way I am thinking of solving this is to create a helper class that
encapsulates the entire database. This class utilizes the DAL components and
passes a SqlConnection object to them which they can use to .Load and
..Store.
Does anyone have an opinions on the pro's and con's of passing an
SqlConnection object to the DAL instead of using a ConnectionString and
getting the DAL components to create their own SqlConnection?
would be interested in hearing opinions from more experienced .NET
developers.
I am building a data access layer that encapsulates my business entities.
For simplicity sake, say I have a .Load and a .Store method for each
business entity in each DAL. Each DAL then has it's own ConnectionString
property and therefore each .Load and .Store method opens it's own
SqlConnection and issues the relevant SQL commands. In theory there should
be no performance loss because of connection pooling.
The problem is that in the application layer I sometimes need to store
multiple business entites within a transaction. Since each DAL opens it's
own SqlConnection this can't be done (or can it?)
The way I am thinking of solving this is to create a helper class that
encapsulates the entire database. This class utilizes the DAL components and
passes a SqlConnection object to them which they can use to .Load and
..Store.
Does anyone have an opinions on the pro's and con's of passing an
SqlConnection object to the DAL instead of using a ConnectionString and
getting the DAL components to create their own SqlConnection?