IDataReader in Data Access Application Block RRS feed

  • Question

  • All of the methods in my BLL that return data with x number of rows to the user interface are returning datatables. Is this not the best practice? Should I be returning an IDataReader instead? If so, how does this work? For instance if a method in a codebehind file iterates through the IDataReader that is returned from my BLL, is it reopening the connection to iterate through the items when I call the Read() method? Also, should I look at returning generic lists instead?
    Monday, August 27, 2007 7:17 PM

All replies

  • As I have said to many people before, why create a dataaccess layer when you can generate.

    A great code generation engine is Codesmith and a great template for code generation which you can find on the site is called Nettiers, we have been using this template for 4 years now with great results. It has a great active community behind it.


    Monday, August 27, 2007 8:11 PM
  • No, you should never pass a data reader across layers; that is bad mojo and will likely result in really bad performance due to unclosed connections.  You should encapsulate your data access/persistence in your data access/persistence layer. 


    Definitely create a domain model or at least some basic DTOs to pass data around.  The tools the other fella is recommending are a good place to start if you're new to the idea (or you just like that solution).
    Monday, August 27, 2007 9:53 PM