none
How to store and test data taken from db / webservices RRS feed

  • Question

  • I'd like to store object data taken from web services and avoid web calls each time I run my application for testing.

    Is there any way to store the data I retrieve online in a file and then call the data the next time from it?

    Tuesday, June 3, 2014 8:37 AM

Answers

All replies

  • Just save the entire webpage to a file with a html extension.

    jdweng

    Tuesday, June 3, 2014 10:32 AM
  • No, it's not my purpose.

    My wish is to retrieve List<MyObject> from a web service or Db, I want to store this data on a file in order to save the calls for the next time I run and test my application.

    Monday, June 9, 2014 8:54 AM
  • You have to save the data to a file with some sort of structure which you can parse when you open the file.  Saving the entire html data to the file contains the structure.  The other choice is to parse the html response and save a portion of the response to the file.  It depends on the type of data you are retrieving what the form at of the data will look like.  A common approach is to savve the results to an XML file.  If you are retrieving table like data from the webpage I would put the data into a dataset object and then save the results to a file using the WriteXML method and make sure I include the schema in the file.  Then you can open the XML file with the ReadXML method and retrieve you save results by parsing the dataset using Linq. 

    jdweng

    Monday, June 9, 2014 9:30 AM
  • If your target browsers all support HTML5 Web SQL extension or IndexedDB extension, you can use it to do what you want.

    Oops. I automatically assumed your application is web application. if that's local application, save data as XML file in "Application Data" folder, similar to what Joel suggested, seems to be good suggestion.

    Alternatively you can try to install SQL Server Compact Edition to run local database there. It depends on what scale your application is and what exactly do you need.



    Tuesday, June 10, 2014 1:47 AM
    Answerer
  • My wish is to retrieve List<MyObject> from a web service or Db, I want to store this data on a file in order to save the calls for the next time I run and test my application.

    If MyObject is marked (or can be marked) with [Serializable] attribute, then consider “Serialization”:

    In the next examples, replace MyObject with List<MyObject>:


    Tuesday, June 10, 2014 5:14 AM