J
Jeff S
I want to instantiate my DAL class within a presentation-layer class, and
have methods in the the DAL return a DataReader. I have seen a number of
posts in this newsgroup that recommended one to never return a DataReader
from a method. The reasoning given is to prevent memory leaks. Sounds
good... but in the ASP.NET Starter Kits - which we are to use as examples
for how to do things - that very practice shows up a lot.
Here's an example right out of the Commerce starter kit:
public SqlDataReader GetProductCategories() {
....
}
Is this practice safe (i.e., won't create memory leaks) if/when we specify
CommandBehavior.CloseConnection as in the following line?
SqlDataReader result =
myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
Thoughts? Opinions? Facts?
Thanks!
have methods in the the DAL return a DataReader. I have seen a number of
posts in this newsgroup that recommended one to never return a DataReader
from a method. The reasoning given is to prevent memory leaks. Sounds
good... but in the ASP.NET Starter Kits - which we are to use as examples
for how to do things - that very practice shows up a lot.
Here's an example right out of the Commerce starter kit:
public SqlDataReader GetProductCategories() {
....
}
Is this practice safe (i.e., won't create memory leaks) if/when we specify
CommandBehavior.CloseConnection as in the following line?
SqlDataReader result =
myCommand.ExecuteReader(CommandBehavior.CloseConnection);
return result;
Thoughts? Opinions? Facts?
Thanks!