I want my Data Access Layer to be built very modular.
Therefore I have data retrieval methods that sometimes are called directly from the business layer and sometimes are called by other data retrieval methods to create object dependencies.
处理DAL数据库链接的最佳方式是什么?
a) Create a new connection in every method and dispose it afterwards.
Good: Easy to write and to work with.
Bad: Many connections are being opened and closed. (performance?)
b) Pass the connection as an (optional) argument.
Good: I could reuse an open connection for multiple commands.
Bad: I have to keep track of the ownership of the connection (who has to close it?) and cannot use the very neat "using" statements.
<>strong>c 还有一些问题? (Connection as oneton maybe?)
这是我首次撰写了一份真正的DAL文件,因此,我确实能够利用你经历的民间人士的一些帮助。
EDIT:由于情况看上去,它有一个伙伴关系。 网上网站项目。