views:

18

answers:

2

I have static data in a single table which I must serialize. I have often read that a DataReader is more performant, if you wish to have read-only data that you traverse only once. If you wish to serialize this information however, would a DataTable be better?

+1  A: 

"Better" is a matter of trade-offs. Data from a data table can be "serialized" by using the WriteXml() method. Problem solved.

If you're up to tuning the performance, you might get some mileage by writing a custom serializer for the reader, but you exchange development time for (we hope) improved performance.

kbrimington
I'm guilty of making an assumption there. Clearly I prefer the DataTable in this case.
Blanthor
A: 

Write a small test for each scenario and use data that is as close to the data that you will see during normal operation.

Then run the tests and measure their performance. The numbers you gather will help you to make a decision if performance is the top priority.

John