Viewing dataset contents without using dataset visualizer
In writing some tests for a project I'开发者_开发问答m working on, I found that the best way for me to get the data back I needed about whether the project was correct was to put results into an ADO.NET DataTable. I got sick of setting breakpoints and waiting for them to be hit so that I could use the DataSet Visualizer to see what my results were, and I wanted to be able to see the results after the test was finished, so I decided to find a quick and dirty way to write the DataTable to a file.
After poking around in Intellisense to try and find a good way to get my DataTable out to a file, I googled a bit and found somebody who had written some code to write a DataTable out to a table in an html file. I spent a few minutes and implemented my own version of this and went on my merry way. I like the html solution because it was super easy to implement, it's totally portable, and it's easy to refresh the page and see the latest test results after making changes to my code.
At this point I'm wondering, however, did I miss an easier/better way of doing this? Keep in mind, the requirements are to be able to visualize the table in actual table form, not serialized as XML or any other less readable format, and it needs to be in a file on the hard drive so that I can come back to it. Any ideas?
I once wrote a series of extension methods to dump a DataTable to CSV quickly... the version on here is only half the solution, but it will allow you to do a one liner dump to CSV. The other half of the solution is just some gold-plating to allow you to choose specific columns, and do custom text formatting. If you are interested I can get that portion to you as well.
I don't know that it provides a better visualization than HTML, but having it in Excel certainly makes for a nice way to sift and sort the data.
精彩评论