The DataReader is more efficient than a DataTable if you only need to show data but not manipulate it. However, to get a DataReader from the data access layer should I leave the connection object open? I think this is also a very big efficiency problem. So is there another approach to this in order to take full advantage of the DataReader?
Share
Yes, the data reader is definitely the most efficient – but you do not want to keep a connection open for a long period of time!
DataReaderto read your data into an entity object; open the connection, read the data, close the connectionThis is probably the most efficient you can get – it’s a bit of work, some boring code, and all, but it’s about as fast as it can be.
If you’re more interested in developer productivity than raw speed, why not use some kind of an ORM to do all this boring, annoying mapping back and forth? Saves you a lot of coding and messy stuff to maintain!