What's a simple/lightweight way to persist objects in .net during development and experimentation?

StackOverflow https://stackoverflow.com/questions/6061404

Question

I'm looking for a simple way to persist objects when experimenting and creating mock UIs or services. I already know what ORM I'll ultimately use later on when producing a releasable product but I don't want to bother setting it all up at this stage.

I'm looking for something that:

  • has low install requirements (ideally, single dll)
  • has low setup requirements (no column definitions, no XML mappings, no table creation..)
  • has low performance (really just needs to support 1 or 2 concurrent users)
  • persists data across application restarts

What I really want, is something like a hashtable that survives application restarts.

What tools would you see appropriate for this? What approaches do you take when you want to persist simple data structures without any muss?

Was it helpful?

Solution

You could just use the framework's built-in Serialization Support.

In terms of your requirements:

  • No install requirements (in framework already)
  • No setup requirements (provided types are serializable)
  • Performance is not as good as most ORMs, but still works.
  • Can persist data to files, or any other source that can take a Stream

OTHER TIPS

well will tricky to tick all these boxes.

I have used SQLite in the past, was quite to mock DBs.

As it comes to persistance, you can try to use native Xml Serialization/JSON or Google's ProtoBuffers.

It is better if you have your Domain Model for your data, that way you can easily Desereliaze/Restore from underlying data (be in simple dump file/xml/db).

that way you will alwyas work with Domain Model and not the underlying data. you can change your underlaying data later on but your Domain Model stays the same

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top