How do I cache my datasource? RRS feed

  • Question

  • I have an app using xml-files as my primary datasource. Every time when I go to my main page my data is read from an xml-file. This data is usually very static. Is it possible to somehow cache this data? This is how it's done:

           protected override void LoadState(object navigationParameter, Dictionary<string, object> pageState)
    // Get all books
                Books books = new Books();
                this.DefaultViewModel["Books"] = books.GetAllBooks();
        public sealed class Books
            /// <summary>
            /// Initializes a new instance of the <see cref="Books"/> class.
            /// </summary>
            public Books()
                // create my datasorce object
    Every time when I go to my main page my data source object will be recreated. Should I store my object in a session variable or how sholud it be done?


    Thursday, October 17, 2013 2:55 PM


  • You can store the data at App level data model once it is read and read only if count of your collection is zero (in this case all books count is zero).  Other way, is to have a singleton session class to store the application level data during initialization and read from  there.

    Thanks, Sachin

    Thursday, October 17, 2013 3:43 PM