G
Guest
How does everyone design the database access layer in an asp.net application?
Two options that come to mind is:
1. create a database class and instanciate it as needed, local to a function
or
2. Provide database access in a base class from which all objects that need
db access will inherit from.
#1 seems wasteful for application that do frequent but light db access.
Option #2 seems even more wasteful, because it adds overhead to the
inheriting class creation, whether or not that class will do db access.
The third option that I have been thinking about is a modification of 1, but
make it as a singleton. Would that help any, or will it become a bottleneck?
I'm just looking for pointers on best practives on implementing the database
layer. I found some in MSDN, but they were more implementation related,
rather than design related. I'd like to cut down on object creation, while at
the same time keep throughput as high as possible. Creating a database class
is usually expensive, since it involves retrieving a connection string,
setting up multiple objects, etc...
any ideas would be appreciated.
Two options that come to mind is:
1. create a database class and instanciate it as needed, local to a function
or
2. Provide database access in a base class from which all objects that need
db access will inherit from.
#1 seems wasteful for application that do frequent but light db access.
Option #2 seems even more wasteful, because it adds overhead to the
inheriting class creation, whether or not that class will do db access.
The third option that I have been thinking about is a modification of 1, but
make it as a singleton. Would that help any, or will it become a bottleneck?
I'm just looking for pointers on best practives on implementing the database
layer. I found some in MSDN, but they were more implementation related,
rather than design related. I'd like to cut down on object creation, while at
the same time keep throughput as high as possible. Creating a database class
is usually expensive, since it involves retrieving a connection string,
setting up multiple objects, etc...
any ideas would be appreciated.