Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. WPF
  4. How to cache data at WPF after the application closed?

How to cache data at WPF after the application closed?

Scheduled Pinned Locked Moved WPF
csharpwpftutorialquestion
9 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    michalush85
    wrote on last edited by
    #1

    Hi, I have WPF app and I need to save the data(Hashtable) into the Cache for one day,also if the app was closed. I try to use ObjectCache but it cleaned in every running. May anyone have a solution, Thanks a lot.

    P 1 Reply Last reply
    0
    • M michalush85

      Hi, I have WPF app and I need to save the data(Hashtable) into the Cache for one day,also if the app was closed. I try to use ObjectCache but it cleaned in every running. May anyone have a solution, Thanks a lot.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      What Cache? If you are trying to save data, you may consider writing out as XML, or saving it to a database or serializing it to file. The choice depends on your application needs and architecture.

      "WPF has many lovers. It's a veritable porn star!" - Josh Smith

      As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

      My blog | My articles | MoXAML PowerToys | Onyx

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        What Cache? If you are trying to save data, you may consider writing out as XML, or saving it to a database or serializing it to file. The choice depends on your application needs and architecture.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        M Offline
        M Offline
        michalush85
        wrote on last edited by
        #3

        Hi, Thanks for fast reply :) . I have an Hashtable that contains objects. And I want to save it not matter what. I will glad if you can explain to me what is the better way to do it(XML or file)? Thanks again.

        P 1 Reply Last reply
        0
        • M michalush85

          Hi, Thanks for fast reply :) . I have an Hashtable that contains objects. And I want to save it not matter what. I will glad if you can explain to me what is the better way to do it(XML or file)? Thanks again.

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          If the objects are all serializable, then it's a simple matter to serialize them to file using something like the XmlSerializer.

          "WPF has many lovers. It's a veritable porn star!" - Josh Smith

          As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

          My blog | My articles | MoXAML PowerToys | Onyx

          M 1 Reply Last reply
          0
          • P Pete OHanlon

            If the objects are all serializable, then it's a simple matter to serialize them to file using something like the XmlSerializer.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            M Offline
            M Offline
            michalush85
            wrote on last edited by
            #5

            Hi, Thanks again. 1)Can I serialize only the Hashtable? Or I need to serialize every object one by one? 2)I have one Hashtable that its objects don't serializable, Is there any way to cache it? Thanks a lot.

            P 1 Reply Last reply
            0
            • M michalush85

              Hi, Thanks again. 1)Can I serialize only the Hashtable? Or I need to serialize every object one by one? 2)I have one Hashtable that its objects don't serializable, Is there any way to cache it? Thanks a lot.

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              Serializing the hash table should serialize the component objects. Remember that they need to be serializable objects in their own right for this to work.

              "WPF has many lovers. It's a veritable porn star!" - Josh Smith

              As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

              My blog | My articles | MoXAML PowerToys | Onyx

              M 1 Reply Last reply
              0
              • P Pete OHanlon

                Serializing the hash table should serialize the component objects. Remember that they need to be serializable objects in their own right for this to work.

                "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                My blog | My articles | MoXAML PowerToys | Onyx

                M Offline
                M Offline
                michalush85
                wrote on last edited by
                #7

                Thanks, I have linq to sql objects and I found that I can serialize the sql by putting this: < Database ... Serialization="Unidirectional > on the dbml file. How can I serialize Hashtable that contain objects like that? Thanks a lot.

                modified on Monday, August 23, 2010 2:43 AM

                P 1 Reply Last reply
                0
                • M michalush85

                  Thanks, I have linq to sql objects and I found that I can serialize the sql by putting this: < Database ... Serialization="Unidirectional > on the dbml file. How can I serialize Hashtable that contain objects like that? Thanks a lot.

                  modified on Monday, August 23, 2010 2:43 AM

                  P Offline
                  P Offline
                  Pete OHanlon
                  wrote on last edited by
                  #8

                  Why would you want to? This indicates that the data is already saved to the database - meaning you don't need to save it to a different storage medium.

                  "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                  As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                  My blog | My articles | MoXAML PowerToys | Onyx

                  M 1 Reply Last reply
                  0
                  • P Pete OHanlon

                    Why would you want to? This indicates that the data is already saved to the database - meaning you don't need to save it to a different storage medium.

                    "WPF has many lovers. It's a veritable porn star!" - Josh Smith

                    As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

                    My blog | My articles | MoXAML PowerToys | Onyx

                    M Offline
                    M Offline
                    michalush85
                    wrote on last edited by
                    #9

                    I have sql query and I want to save every running the row that selected from each table. I found solution for that :D. I mark the dmbl as serializable with

                    <Database... Serialization="Unidirectional">

                    and than use NetDataContractSerializer object to serialize\deserialize. Now, I have another problem, I want to save also the search criterions, every search I save the controls with the search criterions in hashtable, and I want to save it also at xml but the controls are not serializable(I use wpf and telerik controls). Is thare any way to do it? Thanks again.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups